Re: Forward declaring classes



On Fri, 28 Jul 2006 22:30:33 +0200, "Ole Nielsby"
<ole.nielsby@xxxxxxxxxxxx> 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
.



Relevant Pages

  • Re: Forward declaring classes
    ... the compiler will prepare for the worst and assume it ... That article was talking about pointers to member functions. ...
    (microsoft.public.vc.language)
  • Re: New developer with a couple of questions
    ... best left to the compiler?) ... I remember using the "far" keyword in a Borland compiler quite a few ... near pointers were 16 bits long. ... segmented architectures. ...
    (rec.games.roguelike.development)
  • Re: new IL: C (sort of...).
    ... only for "recent" Pascals, ... far pointers weren't really limited, ... in my compiler, I made wchar_t a builtin type (in most cases, aliased to ... I could very well include builtin "managed strings" in the new IL. ...
    (comp.lang.misc)
  • Re: new IL: C (sort of...).
    ... and the frontend compiler needs to be able ... Having very limited pointers is a fact of life in a VM language though, ... vague claims about Pascal's pointer support. ... That is pretty normal for standards (the ...
    (comp.lang.misc)
  • Re: code optimiation
    ... Given that the compiler can often optimise the generated code to use the best sized types available, it's seldom worth specifying "fast" types explicitly. ... pointers and floating point types whose "zero value" might not be all- ... instruction, so the assembler produced for *p++ when used as the ... It will do the same job, and let you write the source code using proper array constructs. ...
    (comp.arch.embedded)