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

C / C++ / MFC

 
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 
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 
vikas amin wrote:
The function that is called depends on object if Virtual
but it depends on the pointer if its Non-virtual


More or less. In fact, with a virtual function, you will have what is called a virtual function table, that is a table that will replace the pointers of the virtual functions of the base class by those of the derived class.


vikas amin wrote:
A derived pointer cannot point to a Base class object


I don't really understand your point here. You can always look at a pointer to a derived class as a pointer to the bass class. That's how polymorphism works: you have a bunch of pointers to one base class but each of them is instancied as a specific derived class (derived1, derived2, ...) and they are all treated as if it was a bas class.

vikas amin wrote:
with type-casting we can assing a derived class pointer to a base class object
say by static_casting , is it a good practise ?



Yes, you can always cast a derived class into its base class (again, that's used with polymorphism). But in general, you don't need to cast it. In general, when you use virtual functions it is for overriding some of the properties of your base class and replace them with properties of your child class.
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 
AnswerRe: KeyBoard Handling Pin
Rajesh R Subramanian22-Jan-06 21:19
professionalRajesh R Subramanian22-Jan-06 21:19 
QuestionRe: KeyBoard Handling Pin
rajeevktripathi23-Jan-06 1:11
rajeevktripathi23-Jan-06 1:11 

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.