On Feb 3, 3:56 pm, "Alf P. Steinbach" <al...@start.no> wrote:
* gordon.is.a.mo...@gmail.com:
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).
You can just forward-declare
class MyClassB;
before the MyClassA definition.
And I want to derive MyClassB from MyClassA because I need access to
the third party library macros:
Access to macros has nothing to do with class derivation.
Cheers, & hth.,
Yes it did help, thanks Alf. This must be the forward declaration
issue that I've heard about then. As for the macros, I should explain
(though I could be wrong anyway) that they are used by the library
class, so I have to subclass it directly or via my derived class,
IYSWIM. I have to pass my derived class into the macro, to set up the
libraries events system.
Much obliged,
Gordy.
.