Rabu, 26 April 2017

How to use virtual functions in Polymorphism (C++)

Virtual Functions   We know that when a base class pointer refers to a derived class object, the extra features in derived class are not available. To access the extra features in the derived class, we make the functions in the base class as virtual. Syntax for creating a virtual function is as follows: 1 2 3 4 5 virtual return–type function–name(params–list) { //Body of function ... }   A class which contains one or more virtual functions is known as a polymorphic class. Following program demonstrates accessing derived class features using virtual functions: 1 2 3 4 5 6

The post How to use virtual functions in Polymorphism (C++) appeared first on Coding Security.


How to use virtual functions in Polymorphism (C++)
read more

Tidak ada komentar:

Posting Komentar