I’ve been trying to add a class to my OpenGL program and this is the code I use to declare and define the class:
class Shell
{
public:
shootCannon(int velocity);
};
void Shell::shootCannon (int velocity)
{
shellVelocity = velocity;
glColor3f(1.0f, 0.0f, 0.0f);
//Draw projectile
glPushMatrix();
glTranslatef(0.0f, 10.0f, 0.0f);
glTranslatef(moveShell, 0.0f, 0.0f);
glBegin(GL_QUADS);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(0.0f,5.0f,0.0f);
glVertex3f(5.0f,5.0f,0.0f);
glVertex3f(5.0f,0.0f,0.0f);
glVertex3f(5.0f, 0.0f, 0.0f);
glVertex3f(5.0f,5.0f,0.0f);
glVertex3f(5.0f,5.0f,-5.0f);
glVertex3f(5.0f,0.0f,-5.0f);
glVertex3f(5.0f, 0.0f, -5.0f);
glVertex3f(5.0f,5.0f,-5.0f);
glVertex3f(0.0f,5.0f,-5.0f);
glVertex3f(0.0f,0.0f,-5.0f);
glVertex3f(0.0f, 0.0f, -5.0f);
glVertex3f(0.0f,5.0f,-5.0f);
glVertex3f(0.0f,5.0f,0.0f);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(0.0f, 5.0f, 0.0f);
glVertex3f(0.0f,5.0f,-5.0f);
glVertex3f(5.0f,5.0f,-5.0f);
glVertex3f(5.0f,5.0f,0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f,0.0f,-5.0f);
glVertex3f(5.0f,0.0f,-5.0f);
glVertex3f(5.0f,0.0f,0.0f);
glEnd();
glPopMatrix();
}
when I compile I get these errors:
Compiling…
Triangle.c
C:\Anthony\OpenGLSB2E\myfiles\Triangle\Triangle.c(29) : error C2061: syntax error : identifier ‘Shell’
C:\Anthony\OpenGLSB2E\myfiles\Triangle\Triangle.c(29) : error C2059: syntax error : ‘;’
C:\Anthony\OpenGLSB2E\myfiles\Triangle\Triangle.c(30) : error C2449: found ‘{’ at file scope (missing function header?)
C:\Anthony\OpenGLSB2E\myfiles\Triangle\Triangle.c(33) : error C2059: syntax error : ‘}’
Error executing cl.exe.
Triangle.exe - 4 error(s), 0 warning(s)
The four errors correspond to the class declaration and not the function definition.
Please help!!!