I am almost 100% sure that I have syntax in both of these classes, however I am getting the following errors:
For CShape.cpp - "error C2011: 'CShape': override of type 'class' For CCircle.cpp -" error CS2504: "CShape": base class undefined "
Here is the complete code for CShape.cpp
#include <iostream>
using namespace std;
class CShape
{
protected:
float area;
virtual void calcArea();
public:
float getArea()
{
return area;
}
}
And here is the code for CCircle.cpp
#include <iostream>
#include "CShape.cpp"
#define _USE_MATH_DEFINES
#include "math.h"
using namespace std;
class CCircle : public CShape
{
protected:
int centerX;
int centerY;
float radius;
void calcArea()
{
area = M_PI * (radius * radius);
}
public:
CCircle(int pCenterX, int pCenterY, float pRadius)
{
centerX = pCenterX;
centerY = pCenterY;
radius = pRadius;
}
float getRadius()
{
return radius;
}
}
As you can see, CShape is the base class that CCircle suppsoed inherits. I'm new to C ++, so I may have the wrong file structures (maybe the base should be in the header file?), If something like that.
source
share