我可以知道爲什麼如果我從輸出中得到類似地址的東西。 任何人都可以告訴我如何使它作爲一個值輸出? 我是新來的指針,並要做鏈接列表。指針,無法打印值
struct node{
int x;
node *next;
};
int main(){
node *root;
root = new node;
root->next = 0;
root->x = 5;
cout << root << endl;
return 0;
}
相關:C++中的'structs'和'classes'沒有區別(默認可見性除外)。您應該爲'node'提供一個構造函數,以便設置'x = 0'和'next = NULL'。 – jww 2014-09-20 00:32:41