G
gordon.is.a.moron
Hello,
I have what I suppose is a simple problem, but I'm not sure the proper
way to fix it. I have two classes, one which I want to derive from
another (the first one which is derived from a third party library
class):
//MyClassA.h
#include"MyClassB.h"
class MyClassA : public LibraryClass
{
friend class TestSuite; //just for test rig
public:
MyClassA(void);
~MyClassA(void);
private:
MyClassB* myb_;
};
The trouble is, it doesn't know about MyClassB unless I add the
include directive for MyClassB in this header (I am using #pragma once
to avoid header file redefinitions, I was using include guards
before).
And I want to derive MyClassB from MyClassA because I need access to
the third party library macros:
#include "MyClassA.h"
class MyClassB: public MyClassA
{
friend class TestSuite; // for test rig
public:
MyClassB(void);
~MyClassB(void);
private:
void LibFunc(libStuff);
};
So the problem is basically ClassA needs to see ClassB and vice versa.
What I have done for now is simply take the MyClassB* myb_ member out
of the MyClassA.h header file and put it into the MyClassA.cpp
implementation file. However this seems a bit untidy to me, as I
thought the class declarations should stay in the header. I'm assuming
there is a better way. Any ideas?
Regards,
Gordy
I have what I suppose is a simple problem, but I'm not sure the proper
way to fix it. I have two classes, one which I want to derive from
another (the first one which is derived from a third party library
class):
//MyClassA.h
#include"MyClassB.h"
class MyClassA : public LibraryClass
{
friend class TestSuite; //just for test rig
public:
MyClassA(void);
~MyClassA(void);
private:
MyClassB* myb_;
};
The trouble is, it doesn't know about MyClassB unless I add the
include directive for MyClassB in this header (I am using #pragma once
to avoid header file redefinitions, I was using include guards
before).
And I want to derive MyClassB from MyClassA because I need access to
the third party library macros:
#include "MyClassA.h"
class MyClassB: public MyClassA
{
friend class TestSuite; // for test rig
public:
MyClassB(void);
~MyClassB(void);
private:
void LibFunc(libStuff);
};
So the problem is basically ClassA needs to see ClassB and vice versa.
What I have done for now is simply take the MyClassB* myb_ member out
of the MyClassA.h header file and put it into the MyClassA.cpp
implementation file. However this seems a bit untidy to me, as I
thought the class declarations should stay in the header. I'm assuming
there is a better way. Any ideas?
Regards,
Gordy