我有一個問題,通常我會明白爲什麼會發生這種情況,我沒有在main方法中聲明函數。但是這個類本身包含了.h文件,該文件具有此方法的原型,所以我對於它不在主函數範圍內的原因有點遺憾。功能沒有在主要的範圍
using namespace std;
#include "Solar.h"
int main(){
initializeGL();
Stars *Alpha = new Stars(5.0);
Planets *Awe = new Planets(.6,2,30,"Awe",0.0,0.0,0.0);
paintGL();
return 0;
}
void Solar::initializeGL(){
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIV
....
}
還有一個功能paintGL()以後,這裏是頭文件
class Solar {
public:
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
.....
private:
.....
};
我不是最好使用C++,所以anyhelp將不勝感激。
這裏是錯誤
Solar.cpp:4: error: declaration of âvoid Solar::initializeGL()â outside of class is not definition
Solar.cpp:5: error: declaration of âvoid Solar::paintGL()â outside of class is not definition
Solar.cpp: In function âint main()â:
Solar.cpp:8: error: âinitializeGLâ was not declared in this scope
Solar.cpp:11: error: âpaintGLâ was not declared in this scope
什麼是錯誤信息,它抱怨哪個功能? – 2010-11-18 21:01:45