struct和指向struct的指针之间的区别

Raa*_*aaj -4 c++ struct pointers

假设我有一个如下所示的结构:

struct node{
  node *next;
  int data;
}
Run Code Online (Sandbox Code Playgroud)

我有一个C++函数,class Stack它定义了一个push类似的操作:

void Stack::push(int n){
    node *temp = new node;
    temp->data = n;
    temp->next = top;
    top = temp;

if(topMin == NULL) {
    temp = new node;
    temp->data = n;
    temp->next = topMin;
    topMin = temp;
    return;
}

    if(top->data < topMin->data) {
        temp = new node;
        temp->data = n;
        temp->next = topMin;
        topMin = temp;
    }
    return;
}
Run Code Online (Sandbox Code Playgroud)

使用之间有什么区别

node *temp = new node;
Run Code Online (Sandbox Code Playgroud)

temp = new node;
Run Code Online (Sandbox Code Playgroud)

在上面的代码?更具体地说,我对这个含义感到困惑.如果temp是a pointer(*),我理解

temp->data 
Run Code Online (Sandbox Code Playgroud)

只是解除引用struct((*temp).data)的指针.同样,使用它意味着什么temp = new node

这仅仅是代表性的差异吗?

Sco*_*ter 5

node *temp = new node;
Run Code Online (Sandbox Code Playgroud)

同时声明temp和初始化它

temp = new node;
Run Code Online (Sandbox Code Playgroud)

分配给已经声明的变量,因此编译器已经知道它是什么类型.