Re: Forward declaring classes
On Fri, 28 Jul 2006 22:30:33 +0200, "Ole Nielsby"
<ole.nielsby@snailmail.dk> wrote:
I have a class hierarchy that looks like:
class B;
class A
{
public:
B *b;
...
}
class B : A
{...}
I read somewhere that when forward declaring class B,
the compiler will prepare for the worst and assume it
is a multiple/virtual inheritance class, and there is a
MS specific __keyword I should write there in order
to inform the compiler that B is single-inheritance and
only a single address is needed.
Unfortunately, I didn't bookmark the page and I simply can't
find it again. Can anybody tell me the word to search for?
What you're thinking of applies to pointers to members. It doesn't apply
here, because you just have a B*, which is a pointer to an object, and
pointers to objects are all the same size. That said, here is a link to the
keyword page, which also links to the compiler options and related pragma
(lots of ways to do this!):
Inheritance Keywords
http://msdn2.microsoft.com/en-us/library/ck561bfk.aspx
--
Doug Harrison
Visual C++ MVP