我对这个类声明有些麻烦,我试图为Dijktra的最短路径算法的openGL实现创建节点.getX(),getY(),getZ()方法导致错误:
错误:ISO C++禁止声明'getX'没有类型
我在ubuntu linux上用g ++编译.命令:g ++ -lglut -lGLU -lGL projecttest.c
#include <cstdarg>
#include <cstdio>
#include <GL/glut.h>
#include <GL/glu.h>
#include <cstdlib>
#include <iostream>
#define kWindowWidth 800
#define kWindowHeight 600
#define NUM_NODES 3
using namespace std;
class Node {
private:
GLfloat x, y, z;
int numLinks;
Node *links[];
public:
Node(GLfloat x, GLfloat y, ...);
~Node();
GLfloat getX();
GLfloat getY();
GLfloat getZ() {return 0.0f;}
} Node;
Node nodes_g[NUM_NODES];
Run Code Online (Sandbox Code Playgroud)
我认为问题出在预处理器宏中.我是openGL的新手,对c ++来说有点新,所以任何建议都很好,但我真正想知道的是为什么我会得到错误.