Reputation: 649
I'm having this (part of) code in my header
class Node
{
Node prevNode;
public:
Node(float nodeXRotation, float nodeYRotation,
float nodeZRotation, float boneLength, float xOffset,
Node prevnode);
}
But its giving me the following error: IntelliSense: incomplete type is not allowed (on line 3: Node prevNode;)
This is where I initialize the 'Nodes'
Node nodes[] = { Node(0, 0, 0, 5, -14, NULL), //Duimkootje 2
Node(0, 0, 0, 5, -9, nodes[0]), //Duimkootje 1
Node(0, 0, 0, 10, 0, nodes[1]), //DUIMHANDBOT
Node(0, 25, 0, 10, 0), //WIJSVINGERHANDBOT
Node(0, 25, 0, 8, -9, nodes[3]), //Wijsvingerkootje 1
Node(0, 25, 0, 7, -17, nodes[4]), //Wijsvingerkootje 2
Node(0, 25, 0, 7, -24, nodes[5]), //Wijsvingerkootje 3
Node(0, 50, 0, 10, 0), //MIDDELVINGERHANDBOT
Node(0, 50, 0, 8, -9, nodes[7]), //Middelvingerkootje 1
Node(0, 50, 0, 8, -17, nodes[8]), //Middelvingerkootje 1
Node(0, 50, 0, 8, -24, nodes[9]), //Middelvingerkootje 1
Node(0, 75, 0, 10, 0), //RINGVINGERHANDBOT
Node(0, 75, 0, 7, -9, nodes[11]), //Ringvingerkootje 1
Node(0, 75, 0, 8, -16, nodes[12]), //Ringvingerkootje 1
Node(0, 75, 0, 8, -24, nodes[13]), //Ringvingerkootje 1
Node(0, 100, 0, 10, 0), //PINKHANDBOT
Node(0, 100, 0, 5, -9, nodes[15]), //Pinkkootje 1
Node(0, 100, 0, 5, -14, nodes[16]), //Pinkkootje 1
Node(0, 100, 0, 6, -19, nodes[17]), //Pinkkootje 1
What am I doing wrong here?
Upvotes: 0
Views: 89
Reputation: 112386
Mooing Duck has the answer in a comment. The problem comes in because you haven't fully defined a Node when you're trying to define one. This means that the compiler can't determine how much memory to allocate.
The solution is do make prevNode
a Node*
, because then you are declaring something with a known size.
Interestingly, if you're coming to C++ from Java., you can get away with this in java. This is because any declaration like that in Java is always an object reference. You don't need to have size information, because what you are doing is always going to "point to" something, not allowcate space for something. That's also why, in Java, you invariably want to do Foo x = new Foo()
.
Upvotes: 3