0

Hello there..i'm trying to implement a tree in C#..the basic node structure is give below

struct node
    {
        public int _x;
        public int _y;
        public int _cost;
        public node _parent;

        public pos(int i, int j,int cost,pos parent)
        {
            _x = i;
            _y = j;
            _cost = cst;
            _parent = parent;
        }
    }

I get the following error when i try to compile : 'node' causes a cycle in the struct layout
This was the way we used to make a tree in C++..but it's confusing in C#..could anyone please enlighten me?? Any help would be appreciated.

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by cool_zephyr
0

hey thanks for the tip..it works but i found a way around..i need to use boxing to store the _parent node in a object variable type

public object _parent;

now in the constructor

_parent=(object)parent;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.