0

I have created a class 'Model'and subclass 'Cube'. Their function declarations are within their respective .h files and the definitions are within their .cpp files. For example:

Model.h

class Model
{
public:
Model(float width, float height, int color);
Model();
~Model();
float width, height;
int color;
void draw();
};

Model.cpp

#include "stdafx.h"
#include "Model.h"

Model::Model(float w, float h, int c)
{
    ......
}

Model::Model()
{
    ......
}

Model::~Model()
{
}

Cube.h

#include "Model.h"

class Cube : public Model
{
public:
    Cube(float size, int color);
    Cube();
    ~Cube();
    int size;
    void draw();
};

Cube.cpp

#include "stdafx.h"
#include "Cube.h"

Cube::Cube(float s, int c)
{
    size = s;
    color = c;
}

Cube::Cube()
{
    size = 1;
    color = 1;
}

void Cube::draw()
{
    ......
}

I declared a Cube object in another class (which has '#include "Cube.h"') by using

Cube cube_a(2.0,1);

However I believe the call to the following function then causes the error

cube_a.draw();

Here is the error:

Error   1   error LNK2019: unresolved external symbol "public: __thiscall Cube::~Cube(void)" (??1Cube@@QAE@XZ) referenced in function "int __cdecl MyFunc(void)" (?MyFunc@@YAHXZ)

Any help would be much appreciated. :)

petehallw
  • 1,034
  • 6
  • 20
  • 46

0 Answers0