Click here to Skip to main content
16,011,849 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: simple array question Pin
20-Jun-01 3:22
suss20-Jun-01 3:22 
GeneralRe: simple array question Pin
20-Jun-01 3:31
suss20-Jun-01 3:31 
GeneralRe: simple array question Pin
20-Jun-01 17:46
suss20-Jun-01 17:46 
GeneralMDI and WS_MAXIMIZE,, Please Pin
mr200320-Jun-01 2:29
mr200320-Jun-01 2:29 
GeneralRe: MDI and WS_MAXIMIZE,, Please Pin
20-Jun-01 3:06
suss20-Jun-01 3:06 
GeneralRe: MDI and WS_MAXIMIZE,, Please Pin
mr200320-Jun-01 3:16
mr200320-Jun-01 3:16 
GeneralRe: MDI and WS_MAXIMIZE,, Please Pin
20-Jun-01 4:09
suss20-Jun-01 4:09 
GeneralVirtual Functions Pin
20-Jun-01 1:35
suss20-Jun-01 1:35 
Im trying to understand virtual functions but cant see what they do. I presumed this would
be the situation I would use them in where I have two identical functions with same prototypes
which do different things, however this works as expected - outputs the base class cout, and
then the derived class one.

class CBadGuy {
public:
CBadGuy();
virtual ~CBadGuy();
void vfunc() { cout << "Base class vfunc.\n"; };

protected:
unsigned int speed;
unsigned int height;
char* description;
};


class CSoldier : public CBadGuy {
public:
CSoldier();
virtual ~CSoldier();
void vfunc() { cout << "Derived class vfunc.\n"; }

protected:
unsigned int numBullets;
};


int main() {

CBadGuy a;
CSoldier b;

a.vfunc();
b.vfunc();

return 0;

}

I cant understand why this works though, I thought that the funciton vfunc() would be ambigous when
I refered to it through object b as sureley this contains its own vfunc as well as the derived one.

Is it the case that I am simply "overloading" the b.func() function

Thanks,
Mark
GeneralRe: Virtual Functions Pin
Matt Gullett20-Jun-01 2:22
Matt Gullett20-Jun-01 2:22 
GeneralRe: Virtual Functions Pin
20-Jun-01 4:35
suss20-Jun-01 4:35 
GeneralHitTest on a CListCtrl Pin
sankar20-Jun-01 0:12
sankar20-Jun-01 0:12 
GeneralRe: HitTest on a CListCtrl Pin
Michael Dunn20-Jun-01 6:29
sitebuilderMichael Dunn20-Jun-01 6:29 
GeneralADO - what am i doing wrong?!! Pin
20-Jun-01 0:08
suss20-Jun-01 0:08 
GeneralRe: ADO - what am i doing wrong?!! Pin
Matt Gullett20-Jun-01 2:24
Matt Gullett20-Jun-01 2:24 
QuestionSerialize() or XML? Pin
Peter Robinson19-Jun-01 22:39
Peter Robinson19-Jun-01 22:39 
GeneralMFC42UD.DLL can't start... Pin
zia_asghar19-Jun-01 22:12
zia_asghar19-Jun-01 22:12 
GeneralRe: MFC42UD.DLL can't start... Pin
Christian Graus20-Jun-01 0:27
protectorChristian Graus20-Jun-01 0:27 
GeneralReturning collection class Pin
parag19-Jun-01 20:31
parag19-Jun-01 20:31 
GeneralRe: Returning collection class Pin
markkuk19-Jun-01 22:50
markkuk19-Jun-01 22:50 
GeneralRe: Returning collection class Pin
Tomasz Sowinski19-Jun-01 22:55
Tomasz Sowinski19-Jun-01 22:55 
QuestionWhat is,for goodness' the problem in this cute code ??? Pin
19-Jun-01 19:50
suss19-Jun-01 19:50 
AnswerRe: What is,for goodness' the problem in this cute code ??? Pin
Michael Dunn19-Jun-01 19:58
sitebuilderMichael Dunn19-Jun-01 19:58 
AnswerRe: What is,for goodness' the problem in this cute code ??? Pin
Christian Graus19-Jun-01 20:02
protectorChristian Graus19-Jun-01 20:02 
Generalok, you are right and What is the problem now Pin
19-Jun-01 21:01
suss19-Jun-01 21:01 
AnswerRe: What is,for goodness' the problem in this cute code ??? Pin
markkuk19-Jun-01 20:39
markkuk19-Jun-01 20:39 

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.