Hi jos,
 
Virtual method mechanism is applicable if you take pointer to the base class 
i.e in this " Dynamic" and not the "object" of the base class.
 
To invoke this method of appropriate class(either human or car) you need to 
take pointer to base class and then assign it to address of derived class.
Regards
Sumant

--- On Wed, 17/2/10, Jos Timanta Tarigan <[email protected]> wrote:


From: Jos Timanta Tarigan <[email protected]>
Subject: [c-prog] virtual method in C++
To: [email protected]
Date: Wednesday, 17 February, 2010, 12:20 AM


  



hi, 

i got question regarding virtual method. so for example i have a class called 
Dynamic which has virtual method move().
There are also two other class that inherited from this Dynamic class, let say 
Human and Car. Both has different concept of move(). 

When I try to call an object, without knowing its a Human or a Car, can C++ 
call the right method for me? So basically I have an object dynamicObj, but i 
dont know its either Human or a Car, can I call dynamicObject. move() without 
casting the object to its specific class (Human or Car) and called the right 
move() method?

thanks in advance
============ ========= ========= === 
http://www.svnstrk. blogspot. com

[Non-text portions of this message have been removed]









      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/

[Non-text portions of this message have been removed]

Reply via email to