Hello.
I have a class "SelectionGroup" which derives from a class "RMFObjectContainer".
RMFObjectContainer has member variables of type SelectionGroup, so I need to include SelectionGroup.h in the header of RMFObjectContainer.h.
However, since SelectionGroup needs RMFObjectContainer to derive from it, I get a typical case of mutual inclusion.
I then proceeded to put the forward declaration
class RMFObjectContainer;
instead of
#include "RMFObjectContainer.h"
into the header of SelectionGroup.h.
However, I receive the following compile error (MSVC2010), as if the forward declaration was unseen:
1>d:\projects\programming\c++\bsc_volumetric_lighting\bsc_volumetric_lighting\rmf\SelectionGroup.h(8): error C2504: 'RMFObjectContainer' : base class undefined |
I assume this is a special problem resulting from me using .h files and leaving .cpp files empty, or I have a misunderstanding regarding #pragma once, and some special handling kicks in?
Code:
RMFObjectContainer.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#pragma once
#include "Solid.h"
#include "Entity.h"
#include "SelectionGroup.h"
class RMFObjectContainer : public RMFObject
{
public:
RMFObjectContainer::RMFObjectContainer(void) {
solids = (Solid**) malloc(sizeof(Solid*));
solidCount = 0;
entities = (Entity**) malloc(sizeof(Entity*));
entityCount = 0;
groups = (SelectionGroup**) malloc(sizeof(SelectionGroup*));
groupCount = 0;
}
RMFObjectContainer::~RMFObjectContainer(void) {
}
int getSolidCount() {
return this->solidCount;
}
void addSolid(Solid* s) {
solids = (Solid**) realloc(solids, sizeof(Solid*) * (solidCount + 1));
*(solids + solidCount) = s;
solidCount++;
}
// Uses insert order
Solid* getSolid(int number) {
if (number >= solidCount || number <= 0)
return NULL;
return *(solids + number);
}
int getEntityCount() {
return this->entityCount;
}
void addEntity(Entity* e) {
entities = (Entity**) realloc(entities, sizeof(Entity*) * (entityCount + 1));
*(entities + entityCount) = e;
entityCount++;
}
// Uses insert order
Entity* getEntity(int number) {
if (number >= entityCount || number <= 0)
return NULL;
return *(entities + number);
}
int getGroupCount() {
return this->groupCount;
}
void addGroup(SelectionGroup* g) {
groups = (SelectionGroup**) realloc(groups, sizeof(SelectionGroup*) * (groupCount + 1));
*(groups + groupCount) = g;
groupCount++;
}
// Uses insert order
SelectionGroup* getGroup(int number) {
if (number >= groupCount || number <= 0)
return NULL;
return *(groups + number);
}
private:
Solid** solids;
int solidCount;
Entity** entities;
int entityCount;
SelectionGroup** groups;
int groupCount;
};
|
^ Solid.h and Entity.h include a few other headers which are unrelated.
SelectionGroup.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#pragma once
//#include "RMFObjectContainer.h"
class RMFObjectContainer;
class SelectionGroup : public RMFObjectContainer
{
public:
SelectionGroup::SelectionGroup(void) {
}
SelectionGroup::~SelectionGroup(void) {
}
};
|
Any help is appreciated! Thanks in advance!