On Jan 12, 4:46=A0pm, hankyp...@[EMAIL PROTECTED]
wrote:
> Hi All,
>
> I need a tree data structure for my application. It is the non -
> cyclic
> simple tree where i can have any number of children node and each
> child can recursively become a sub tree like a normal tree. =A0Now the
> thing is i can popullate my tree at compile time like a global data.
> Since
> i know my tree definition at compile time, instead of using pointers
> to point to siblings or child nodes, i am planning to use the array
> with undefined length like int a[] =3D {1,2}.
>
> Issue is if i declare complete tree at one place like this, my code
> become unreadable and unmanageable because of nested and high depth
> of
> tree. Even if i format code with 2 white space, it will become very
> big with around 10-20 levels and 20 nodes at each level. Also
> declaring each node with some logical name instead of an array
> element
> at some position will also make it easy to modify in future when
> required.
>
> I was planning to declare each node seperately and then use that in
> tree as =A0reference
> like
> =A0Structure Node leaf1 =3D {1,1,1};
> =A0Structure Node leaf2 =3D {1,1,1};
> =A0Structure Node leaf3 =3D {1,1,1};
>
> and then
> =A0 =A0 Structure Node =A0node[] =A0=3D {1,1,1, leaf1, leaf2, leaf3};
>
> But the problem is i can not reference a variable like this as global
> data above my main method like this
>
> #include <stdio.h>
>
> =A0Structure Node leaf1 =3D {1,1,1};
> =A0Structure Node leaf2 =3D {1,1,1};
> =A0Structure Node leaf3 =3D {1,1,1};
>
> =A0 Structure Node =A0node[] =A0=3D {leaf1, leaf2, leaf3};
>
> int main()
> {
> =A0/// do processing;
> return 0;
>
> }
>
> It gives compilation error "error: initializer element is not
> constant". Pls let me know how can i handle such situation.
>
> Regards
> -
> --
> comp.lang.c.moderated - moderation address: c...@[EMAIL PROTECTED]
-- you
must
> have an appropriate newsgroups line in your header for your mail to be
see=
n,
> or the newsgroup name in square brackets in the subject line. =A0Sorry.
That is an interesting problem. I am going to look at it on my Redhat
C++ compiler
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|