Click here to Skip to main content
15,886,798 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: calling base class function with derived class pointer. Pin
Owner drawn22-Jan-06 19:27
Owner drawn22-Jan-06 19:27 
GeneralRe: calling base class function with derived class pointer. Pin
vikas amin22-Jan-06 19:49
vikas amin22-Jan-06 19:49 
GeneralRe: calling base class function with derived class pointer. Pin
Owner drawn22-Jan-06 20:03
Owner drawn22-Jan-06 20:03 
AnswerRe: calling base class function with derived class pointer. Pin
Stephen Hewitt22-Jan-06 19:41
Stephen Hewitt22-Jan-06 19:41 
GeneralRe: calling base class function with derived class pointer. Pin
vikas amin22-Jan-06 20:12
vikas amin22-Jan-06 20:12 
GeneralRe: calling base class function with derived class pointer. Pin
Stephen Hewitt22-Jan-06 20:15
Stephen Hewitt22-Jan-06 20:15 
GeneralRe: calling base class function with derived class pointer. Pin
vikas amin22-Jan-06 20:27
vikas amin22-Jan-06 20:27 
GeneralRe: calling base class function with derived class pointer. Pin
Cedric Moonen22-Jan-06 21:41
Cedric Moonen22-Jan-06 21:41 
Also, to complete the other answers, the rule with the virtual keyword is as follow: if the function is not virtual, it will call the function from which the pointer is related to. Take this example:

void main()<br />
{<br />
Base *bas_ptr=new Derived;<br />
<br />
der_ptr->fun1();<br />
} <br />


In this case, if fun1 was not declared as virtual, the function called would be the one from the base class, because your pointer is of the type Base, even if it has been created as a Derived class. Now, take the same example but instead declare fun1 as virtual, then in that case the function that will be called would be the one from the child class.

Hope it makes thing more clear Wink | ;)
GeneralRe: calling base class function with derived class pointer. Pin
vikas amin22-Jan-06 22:40
vikas amin22-Jan-06 22:40 
GeneralRe: calling base class function with derived class pointer. Pin
Cedric Moonen22-Jan-06 22:49
Cedric Moonen22-Jan-06 22:49 
QuestionPause in between Pin
Vineethg22-Jan-06 19:02
Vineethg22-Jan-06 19:02 
AnswerRe: Pause in between Pin
kakan22-Jan-06 19:19
professionalkakan22-Jan-06 19:19 
QuestionOS Pin
Tuotrut22-Jan-06 18:46
Tuotrut22-Jan-06 18:46 
AnswerRe: OS Pin
waxie22-Jan-06 18:53
waxie22-Jan-06 18:53 
AnswerRe: OS Pin
Sebastian Schneider22-Jan-06 20:51
Sebastian Schneider22-Jan-06 20:51 
AnswerRe: OS Pin
Toby Opferman23-Jan-06 9:00
Toby Opferman23-Jan-06 9:00 
QuestionGet IP address of computer (MFC/VC++) Pin
waxie22-Jan-06 18:10
waxie22-Jan-06 18:10 
AnswerRe: Get IP address of computer (MFC/VC++) Pin
JonEngle22-Jan-06 19:36
JonEngle22-Jan-06 19:36 
AnswerRe: Get IP address of computer (MFC/VC++) Pin
eli1502197922-Jan-06 21:18
eli1502197922-Jan-06 21:18 
Questionhow to get all computer name in a network fastly. Pin
baldha rakesh22-Jan-06 17:53
baldha rakesh22-Jan-06 17:53 
Questionenable and disable the dialog controls Pin
Anu_Bala22-Jan-06 17:52
Anu_Bala22-Jan-06 17:52 
AnswerRe: enable and disable the dialog controls Pin
Owner drawn22-Jan-06 18:17
Owner drawn22-Jan-06 18:17 
AnswerRe: enable and disable the dialog controls Pin
David Crow23-Jan-06 4:17
David Crow23-Jan-06 4:17 
AnswerRe: enable and disable the dialog controls Pin
domehead23-Jan-06 7:03
domehead23-Jan-06 7:03 
QuestionKeyBoard Handling Pin
rajeevktripathi22-Jan-06 17:51
rajeevktripathi22-Jan-06 17:51 

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.