Click here to Skip to main content
15,911,482 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multithreading and classes. Pin
Tim Deveaux18-Jun-01 13:54
Tim Deveaux18-Jun-01 13:54 
GeneralRe: Multithreading and classes. Pin
John Uhlenbrock18-Jun-01 14:04
John Uhlenbrock18-Jun-01 14:04 
GeneralRe: Multithreading and classes. Pin
Thomas Freudenberg19-Jun-01 2:05
Thomas Freudenberg19-Jun-01 2:05 
GeneralOLE Drag Drop in an ActiveX control Pin
18-Jun-01 11:48
suss18-Jun-01 11:48 
GeneralGetting It Out Of The Recycling Bin Pin
Swinefeaster18-Jun-01 11:33
Swinefeaster18-Jun-01 11:33 
GeneralRe: Getting It Out Of The Recycling Bin Pin
Carlos Antollini18-Jun-01 11:55
Carlos Antollini18-Jun-01 11:55 
GeneralRe: Getting It Out Of The Recycling Bin Pin
Swinefeaster18-Jun-01 22:35
Swinefeaster18-Jun-01 22:35 
GeneralC++ - Inheritance Pin
Ganesh Ramaswamy18-Jun-01 11:08
Ganesh Ramaswamy18-Jun-01 11:08 
Hi,
I have a doubt, though it might seem silly to many. But, please help.
My doubt is in the following code
class Base
{
protected:
int i;
public:
Base(){ printf("Base Constructor\n");}
void MyPrint(){ printf("Value of i(Base) = %d",i); }
};

class Derv: public Base
{
public:
Derv(){ i = 20; }
};

//a global function
void GlobalPrint(Base objB) { objB.MyPrint(); }


void main()
{
Derv Objd;
Base Objb = Objd;
ObjB.MyPrint(); // in this case what happens is that the base class version of MyPrint is called. But the value of "i" is a junk
}

// but if my main is something like this
void main()
{
Derv Objd;
GlobalPrint(Objd); // in this case the base class verion of MyPrint is called inside the
// global function. but the value of i is 20.
}


Can u please explain whats happening. I thought in the first implmentation also an implicit conversion should take place and value of i should be 20. But its not. So please help me

Regards,
Ganesh.M.Ramaswamy
GeneralRe: C++ - Inheritance Pin
18-Jun-01 11:38
suss18-Jun-01 11:38 
Questionfixing "Cannot find the definition (implementation) of this function"? Pin
18-Jun-01 10:59
suss18-Jun-01 10:59 
AnswerRe: fixing Pin
18-Jun-01 21:50
suss18-Jun-01 21:50 
QuestionLoad *.c at runtime? Pin
18-Jun-01 10:51
suss18-Jun-01 10:51 
AnswerRe: Load *.c at runtime? Pin
Christian Graus18-Jun-01 17:10
protectorChristian Graus18-Jun-01 17:10 
AnswerRe: Load *.c at runtime? Pin
18-Jun-01 18:07
suss18-Jun-01 18:07 
GeneralRe: Load *.c at runtime? Pin
19-Jun-01 3:26
suss19-Jun-01 3:26 
QuestionIs there a CD-ROM? Pin
Rickard Andersson2018-Jun-01 10:43
Rickard Andersson2018-Jun-01 10:43 
AnswerRe: Is there a CD-ROM? Pin
Gero Gerber18-Jun-01 10:52
Gero Gerber18-Jun-01 10:52 
AnswerRe: Is there a CD-ROM? Pin
19-Jun-01 7:31
suss19-Jun-01 7:31 
GeneralKeyboard acces... Pin
Rickard Andersson2018-Jun-01 10:39
Rickard Andersson2018-Jun-01 10:39 
GeneralRe: Keyboard acces... Pin
Mukkie19-Jun-01 6:39
Mukkie19-Jun-01 6:39 
GeneralPlus! Settings, use large icons, et. al Pin
18-Jun-01 10:35
suss18-Jun-01 10:35 
Generalbitmaps and PatBlt Pin
michaelh18-Jun-01 10:28
michaelh18-Jun-01 10:28 
QuestionMenu in a dialog window ? Pin
18-Jun-01 9:03
suss18-Jun-01 9:03 
AnswerRe: Menu in a dialog window ? Pin
18-Jun-01 10:05
suss18-Jun-01 10:05 
GeneralRe: Menu in a dialog window ? Pin
18-Jun-01 10:42
suss18-Jun-01 10:42 

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.