Reputation: 1
struct xampl {
int x;
char y;
};
struct xampl InstaceOfxampl;
struct xampl *PointerToxampl;
struct xampl &new_struct;
We are creating a simple instance in first case, and a pointer to structure xampl in second. However what does the third declaration mean? How is it handled differently as compared to other two in code?
Upvotes: 0
Views: 2824
Reputation: 67319
you can access a member of the structure:
.
->
you can store the address of the first one in the second one like:
PointerToxampl=&InstaceOfxampl;
as everybody else said third one is invalid thing to do.if you want to decalre a reference.it should be done as below:
struct xampl &new_struct=InstaceOfxampl;
Upvotes: 0
Reputation: 23727
In C++, struct xampl &new_struct
declares a reference (however, it is invalid, because a reference have to be initialized). In C, it does not mean anything, here.
Upvotes: 5