|
From: Giovanni Dicanio on 26 Apr 2008 17:25 "Z.K." <nospam(a)nospam.net> ha scritto nel messaggio news:eUv3Bo9pIHA.4884(a)TK2MSFTNGP06.phx.gbl... > The class forward technique is kind of new to me and I have never really > understood it that well. I don't remember reading of such a thing in any > of my text books, but I will review them to be sure. The concept is simple: by using a forward declaration, you are telling the compiler that e.g. the class that you are forward-declaring is defined somewhere else in code. // FILE: X.h // DESC: Header file for class X // Forward declaration // Tells the compiler that class Y is defined somewhere else... class Y; class X { .... private: Y * pY; // Y class is forward declared }; Considering that a pointer (like "Y* ") is 4 bytes on 32 bits architectures, even if the compiler does not know the exact size of the class you are forward-declaring, the compiler certainly can alloc a slot of 4 bytes inside class X to store the pointer to that Y class. HTH, Giovanni
First
|
Prev
|
Pages: 1 2 3 Prev: checking whether two vector references / pointers are the same Next: $$$ on line hero $$$ |