Class's member is not seen

Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef NODE_H
#define NODE_H

#include "Container.h"

class Container;

class Node
{
 public:
    enum NodeType{ FlowOut, FlowIn, DataOut, DataIn, MemOut, MemIn};

    Node(NodeType _type);
    void Connect(Container* &_cont);
    void* getLink();

 private:
    void* link;
    NodeType type;
};
#endif // NODE_H 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "../include/Node.h"

Node::Node(NodeType _type)
{
 type = _type;
}

void Node::Connect(Container* &_cont)
{
 link = (_cont->getNode(type))->getLink();
}

void Node::getLink() const
{
 return link;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef CONTAINER_H
#define CONTAINER_H

#include "Node.h"

class Node;

class Container
{
 public:
     enum State{ INACTIVE, EXECUTE, PASSIVE };

     Container();
     virtual ~Container();
     Node* getNode(Node::NodeType _type);

 private:
     struct U2{ unsigned val:2; };  // 0..4   (2 bits)

     int numNodes;
     U2 state;
     Node *node[/*numNodes*/6];
};

#endif // CONTAINER_H


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "../include/Container.h"

Container::Container()
{
 node[Node::FlowOut] = new Node(Node::FlowOut);
 node[Node::FlowIn]  = new Node(Node::FlowIn);
 node[Node::DataOut] = new Node(Node::DataOut);
 node[Node::DataIn]  = new Node(Node::DataIn);
 node[Node::MemOut]  = new Node(Node::MemOut);
 node[Node::MemIn]   = new Node(Node::MemIn);

 numNodes = 6;
 state = INACTIVE;
}

Container::~Container()
{
 delete node[Node::FlowOut];
 delete node[Node::FlowIn];
 delete node[Node::DataOut];
 delete node[Node::DataIn];
 delete node[Node::MemOut];
 delete node[Node::MemIn];
}

Node* Container::getNode(Node::NodeType _type)
{
 return node[_type];
}



The compiler gives 2 errors:
Container.h|15|error: expected ';' at end of member declaration
Container.h|15|error: expected ')' before '_type'

Both classes need forward declaration of themselves, but I guess that breaks the code. I probably messed up in that because the enum usage looks ok.
It seems that the definition of Container does not see the definition of Node. So the compiler does not know what is NodeType.
"Class's member is not seen" ...Yep, that's the title if you haven's noticed!

But how to fix the errors?
Last edited on
Topic archived. No new replies allowed.