Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ok... quick and easy... cin.flush(); Pin
SilverShalkin20-May-02 3:53
SilverShalkin20-May-02 3:53 
GeneralRe: ok... quick and easy... cin.flush(); Pin
Abin20-May-02 5:58
Abin20-May-02 5:58 
QuestionC++ question? Pin
19-May-02 15:32
suss19-May-02 15:32 
AnswerRe: C++ question? Pin
Nish Nishant19-May-02 15:42
sitebuilderNish Nishant19-May-02 15:42 
GeneralRe: C++ question? Pin
19-May-02 16:11
suss19-May-02 16:11 
GeneralRe: C++ question? Pin
Christian Graus19-May-02 16:53
protectorChristian Graus19-May-02 16:53 
GeneralRe: C++ question? Pin
20-May-02 20:57
suss20-May-02 20:57 
AnswerRe: C++ question? Pin
Alvaro Mendez20-May-02 11:23
Alvaro Mendez20-May-02 11:23 
It depends on how you're accessing class B. If it's by pointer or reference, then you only need to provide A with a forward declaration of B:

class B;  // forward declaration
 
class A
{
private:
    B* m_pB;  // by pointer
    B& m_b;   // by reference
};


This is because you're only declaring B as a pointer or reference, which are always 4 bytes (in Win32), so the compiler doesn't need anymore information to determine the size of A.

If you were going to declare an instance of B directly inside of A, then the compiler would need to know how big B is so that it could add it to A's size. For that, the compiler needs B's definition. So you need to put B's definition on top of A, which is typically done by including the header file where it's defined (B.h):

#include "B.h"   // contains B's definition (which the compiler needs below)
 
class A
{
private:
    B m_b;    // by value
};



I hope to have shed some light on this stuff.

Regards,
Alvaro



Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
GeneralRe: C++ question? Pin
21-May-02 15:35
suss21-May-02 15:35 
GeneralFocus problems with list control Pin
paulb19-May-02 15:06
paulb19-May-02 15:06 
GeneralRe: Focus problems with list control Pin
Shog919-May-02 16:24
sitebuilderShog919-May-02 16:24 
GeneralRe: Focus problems with list control Pin
paulb19-May-02 17:30
paulb19-May-02 17:30 
GeneralDeterming video card Pin
19-May-02 14:11
suss19-May-02 14:11 
GeneralRe: Determing video card Pin
Paul M Watt19-May-02 21:45
mentorPaul M Watt19-May-02 21:45 
GeneralRe: Determing video card (EnumDisplayDevices problem...) Pin
20-May-02 2:11
suss20-May-02 2:11 
GeneralRe: Determing video card (EnumDisplayDevices problem...) Pin
Paul M Watt20-May-02 4:52
mentorPaul M Watt20-May-02 4:52 
GeneralRe: Determing video card (EnumDisplayDevices problem...) Pin
Paul M Watt20-May-02 4:53
mentorPaul M Watt20-May-02 4:53 
Generalcompiler problem Pin
Steve L.19-May-02 12:26
Steve L.19-May-02 12:26 
GeneralRe: compiler problem Pin
Joaquín M López Muñoz19-May-02 12:40
Joaquín M López Muñoz19-May-02 12:40 
GeneralUnhandled exeption when using shell functions Pin
redeemer19-May-02 11:17
redeemer19-May-02 11:17 
GeneralRe: Unhandled exeption when using shell functions Pin
Joaquín M López Muñoz19-May-02 11:42
Joaquín M López Muñoz19-May-02 11:42 
GeneralRe: Unhandled exeption when using shell functions Pin
redeemer19-May-02 11:47
redeemer19-May-02 11:47 
GeneralRe: Unhandled exeption when using shell functions Pin
Joaquín M López Muñoz19-May-02 12:09
Joaquín M López Muñoz19-May-02 12:09 
GeneralRe: Unhandled exeption when using shell functions Pin
redeemer19-May-02 12:07
redeemer19-May-02 12:07 
GeneralRe: Unhandled exeption when using shell functions Pin
Joaquín M López Muñoz19-May-02 12:17
Joaquín M López Muñoz19-May-02 12:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.