[RESOLVED] Dynamic ? Nested structs
Good day to everyone. I am a bit lost , and I hope someone could help me a bit :)
Lets say I have a struct which could have the same look of struct as itself and that child struct the same ant so on ..
How to declare it....
Pseudo code
Code:
struct1
{
variables;
next_struct_like_struct 1
{
variables;
next_struct_like_struct_before.....
}
}
Thankyou in advice.
Re: Dynamic ? Nested structs
You could use a member pointer, e.g.,
Code:
struct X
{
int z;
X* next;
};
Re: Dynamic ? Nested structs
So you saying. that X* next will make lika a copy of new struct.
Hmm somehow I was trying to make it work like a class with (new = ) and constructor :x
Re: Dynamic ? Nested structs
Quote:
Originally Posted by ulumulu
that X* next will make lika a copy of new struct.
No, but it can point to another struct of the same type, or even point to the same struct.
Quote:
Originally Posted by ulumulu
Hmm somehow I was trying to make it work like a class with (new = ) and constructor :x
Go ahead. You would need to consider ownership though: does an object own another object of the same type, or is it merely associated with that other object?
Re: Dynamic ? Nested structs
Well relation between objects are actually weak. Anyway thankyou laserLight.