【发布时间】:2019-03-20 07:36:57
【问题描述】:
我有一个存储内存地址的int* 变量,例如地址0x28c1150。
我想知道,地址中存储了什么值。
编辑:
struct list {
int value;
list *next;
list *head = NULL;
void push(int n);
void select();
void pop();
void top();
};
void list::push(int value) {
list *temp = new list;
temp->value = value;
temp->next = head;
head = temp;
}
void list::top(){
list * temp = new list;
cout << head;
}
我想打印我的列表顶部
【问题讨论】:
-
或指向的值:
std::cout << *variable << "\n"; -
如果没有type,就不能有值。您期望什么类型的价值?
-
我期待 int
-
int*与您的代码有什么关系。我在您的代码中没有看到任何int*。 -
您的
top()函数泄漏内存。您分配了一个新列表,然后就忘了它。