My code looks like this:
#include <iostream>
struct Node {
   double data;
   Node* next;
};
int main(){
   Node* a;
   a = new Node;
}
I am having a hard time understanding why the assignment would work for a pointer. Because a is type Node* but the new node is type Node.
At the beginning of my class, I was taught that pointer assignment needs to always be an address.
For example:
int * x;
int y = 5;
This would be allowed:
x = &5;
But this wouldn't:
x = y;
So, by that same logic, shouldn't the assignment of Node* a; be:
a = &(new Node);
Instead of:
a = new Node;
?
 
     
     
     
    