C++ Console Lesson 42: Virtual Member Functions

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
18,456
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 1, 2009

More at http://xoax.net

This C++ video tutorial explains how to use virtual member function pointers and virtual destructors in C++. Virtual functions are used to override functions in base clases and are the basis of type polymorphism and object-oriented programming in C++.

Please submit all questions to our forum: http://xoax.net/forum/

  • likes, 7 dislikes

Link to this comment:

Share to:

Top Comments

  • thanks, great set of tutorials

  • 0.0!

    thanks for these vids, i've watched them all now

see all

All Comments (18)

Sign In or Sign Up now to post a comment!
  • this is very good for student

    

  • Great instruction, the only critique is that it would be nice to be able to view the entire code versus the zooming in on a section some times.

  • I hate the word pointer

  • @tronulu if the a base destructor/method is virtual all methods that are derived from it will be virtual

  • in 5:38

    he says we "only" need to change the base destructor to virtual BUT

    he has also changed the derived destructor to virtual, without mentioning why!

    so why does he do that?

  • Virtual functions are great for implementing interfaces. Think of a game class called GameObject that has two functions: virtual void Initialize() and virtual void Update(). You'll be creating many different types of GameObjects such as people, bullets, cars, chess pieces, etc. Instead of writing custom code to initialize and update every object, you'd like to be able to iterate over an array of GameObject pointers. Each derived GameObject implements its own Initialization and Update code.

  • thanx , it realy helpd me to understand the logic very easily and very quickly.

  • @atifplus

    basically having virtual functions in base class let the derived class object use their own functions and if derived class don't have the function defined the base class will provide the function. As far as the use u never know when u can run into issue where u might need this type of functionality it is just a type of tool available for disposal :)

  • @hemagoku

    the purpose of virtual function is to have the priority. i.e let say your base class has function and derived class has a same function as well. If you created a base class pointer and point it to derived class object and call that one function due to the type of the pointer base class function will be executed unless the function is virtual and at that point derived class object function will be able to override the base class function.

  • thanks a bunch.Awesome for noobs as well as refreshing concepts.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more