I'm having frustrations with C++... when I try and compile my code (as simplistic as it is), I keep getting a 'Shape' not declared error, but I'm fairly certain that I've written it correctly.
shape.h
#ifdef shape_h
#define shape_h
using namespace std;
class Shape {
public:
Shape();
virtual ~Shape() = 0;
virtual void draw() = 0;
};
class Square : public Shape
{
public:
Square();
~Square();
};
#endif
shape.cpp
#include "shape.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
Shape::Shape() {}
Shape::~Shape() {}
Square::Square() {}
void Square::draw()
{
glColor3f(1.0,0.0,0.0);
glRectf(-0.5,-0.5,1.0,1.0);
}
error
shape.cpp:11: error: ‘Shape’ has not been declared
shape.cpp:11: error: ISO C++ forbids declaration of ‘Shape’ with no type
shape.cpp:12: error: expected constructor, destructor, or type conversion before ‘::’ token
shape.cpp:14: error: ‘Square’ has not been declared
shape.cpp:14: error: ISO C++ forbids declaration of ‘Square’ with no type
shape.cpp:16: error: ‘Square’ is not a class or namespace
shape.cpp: In function ‘int Shape()’:
shape.cpp:11: warning: control reaches end of non-void function
shape.cpp: In function ‘int Square()’:
shape.cpp:14: warning: control reaches end of non-void function
make: *** [shape.o] Error 1
any ideas?