I have this project im working on. It will eventually be an implementation of Dijkstra's shortest path algorithm using some c++ classes and openGL to visualize it.
My problem is creating a data structure to hold an array of nodes that I can draw to the screen. Im sure there is something im missing, ive researched online for hours but I couldnt find anything that could help me with my problem. Here is the code thats giving me problems:
Node is declared in a header file. Ill go ahead and include that whole file.
"Node.h":
Global array:Code:#include <GL/glut.h> #include <GL/glu.h> #include <GL/gl.h> class Node { private: GLfloat x, y, z; int numLinks; Node *links[]; public: //Node(GLfloat x, GLfloat y, ...); Node(); Node(GLfloat x, GLfloat y); ~Node(); GLfloat getNodeX(); GLfloat getNodeY(); GLfloat getNodeZ() {return 0.0f;} GLvoid setNodeX(GLfloat x); GLvoid setNodeY(GLfloat y); } Node; Node::Node() { this->x = 0.0f; this->y = 0.0f; this->z = 0.0f; } Node::Node(GLfloat x, GLfloat y) { this->x = x; this->y = y; this->z = 0.0f; } /*Node::Node(GLfloat x, GLfloat y, int numLinks, ...) { va_list arguments; va_start(arguments, numLinks); for (int i = 0; i < numLinks; i++) { this.links[i] = va_arg(arguments, *Node); } this.x = x; this.y = y; this.z = 0.0f; }*/ GLfloat Node::getNodeX() { return this->x; } GLfloat Node::getNodeY() { return this->y; } GLvoid Node::setNodeX(GLfloat x) { this->x = x; } GLvoid Node::setNodeY(GLfloat y) { this->y = y; } Node::~Node() { }
Code:Node *nodes[NUM_NODES];g++ gives me these errors which correspond to the 4 lines above. The first error being the global variable.Code:int makeNodes() { nodes[0] = new Node(0.0f, 0.0f); }
DijkstraShortestPath.cpp:11:1: error: ‘Node’ does not name a type
DijkstraShortestPath.cpp: In function ‘int makeNodes()’:
DijkstraShortestPath.cpp:58:2: error: ‘nodes’ was not declared in this scope
DijkstraShortestPath.cpp:58:17: error: expected type-specifier before ‘Node’
DijkstraShortestPath.cpp:58:17: error: expected ‘;’ before ‘Node’
I would appreciate some suggestions on how to fix this, or even suggestions on a better way to keep track of my nodes.



LinkBack URL
About LinkBacks


