This forum has been archived. Please start a new discussion on GitHub.

forgot me, but I can't declare a recursion nested struct...

struct Nav; // i can not do this;
sequence<Nav> NavItems;
struct Nav{
string title;
NavItems children;

because the Nav has any small sub Nav, I'd like to got it by once.
somebody help me ?


  • i can't use class, because it must create

    a class object instance in server side and post a proxy to client.
    I just want to send a little bit of complex data to client side.

    can you enable Forward Declare a struct?

    struct a;
    sequence<a> as;
    struct a{
    as children;

    nonmutating a get();
  • mes
    mes California
    You cannot forward-declare a struct, you have to use classes for this purpose:
    class Nav;
    sequence<Nav> NavItems;
    class Nav
        string title;
        NavItems children;
    You can use classes as "fancy structs", i.e., as structs with inheritance. You do not have to use classes strictly by proxies. If your classes have no operations, then you do not need to install factories for them. Take a look at the code in demo/Ice/value for an example of passing classes by value.

    Take care,
    - Mark
  • great, thank you!