Question

So I have class A, B, and C. Class A is the parent or base class and B and C inherit from it. I get errors saying "base class undefined" I believe it's because class A is included in both header files of B and C? This is in my main code.

#include "BoundingSphere.h"
#include "OrientedBoundingBox.h"

And this is the shortened version of BoundingSphere.h

#include "Model.h"
#include "Common\xnacollision.h"

class BSModel : public Model
{
};

OrientedBoundingBox.h would be the same thing just with class OBBModel. So why am I getting the error Error 2 error C2504: 'Model' : base class undefined c:\users\X\desktop\project\boundingsphere.h 9 1 PhysicsDemo

I'm also getting 'Model' redefinition error.

Was it helpful?

Solution

Try to put #pragma once in the top of all the header files in your project to prevent re-including them once they have already been included.

#pragma once is supported on all modern compilers, but not standard. You can also use include guards which are standard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top