-
June 18th, 2009, 12:47 AM
#1
[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.
Share and always try to give back more.
-
June 18th, 2009, 12:53 AM
#2
Re: Dynamic ? Nested structs
You could use a member pointer, e.g.,
Code:
struct X
{
int z;
X* next;
};
-
June 18th, 2009, 12:57 AM
#3
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
Share and always try to give back more.
-
June 18th, 2009, 01:07 AM
#4
Re: Dynamic ? Nested structs
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.
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?
-
June 18th, 2009, 01:29 AM
#5
Re: Dynamic ? Nested structs
Well relation between objects are actually weak. Anyway thankyou laserLight.
Share and always try to give back more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|