question
what does the " *start" do?
why use "temp = new(struct node); instead of temp=new node?"
ty
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
struct node
{
int info;
struct node *next;
struct node *prev;
}*start;
temp = new(struct node);
|
> what does the " *start" do?
It is equivalent to:
1 2 3 4 5 6
|
struct node
{
// ...
};
node* start ; // variable of type pointer to node
|
> why use "temp = new(struct node); instead of temp=new node?"
There is no need to use an elaborated type specifier in this case.
Just write:
node* temp = new node{} ;
elaborated type specifier:
https://en.cppreference.com/w/cpp/language/elaborated_type_specifier
Thank You
Topic archived. No new replies allowed.