by Dinesh Thakur Category: Classes in C++

A virtual function is a function that is declared as virtual in a base class. A virtual function is always preceded by the keyword virtual. Virtual functions employ late binding by allocating memory space during execution time and not during compilation time. In this case when a pointer of the base class is defined in a main() function and derived class object's address is passed on to the base class pointer, then calling the overridden function will invoke the derived class member function and not the base class member function as mentioned earlier. Following is a program to illustrate the use of virtual functions.

by Dinesh Thakur Category: Classes in C++

Objects are the small, self-contained and modular units with a well-defined boundary. An Object is a Real Word Thing Which performs a Specific Task. An object consists of a state (Properties) and behavior (Method). The state of an object is one of the possible conditions that an object can exist in and is represented by its characteristics or attributes or data or Properties of Object. The behavior of an object determines how an object acts or behaves and is represented by the operations that it can perform. In OOP, the attributes of an object are represented by the variables and the operations are represented by the functions.

by Dinesh Thakur Category: Classes in C++

The members of a class can be directly accessed inside the class using their names. However, accessing a member outside the class depends on its access specifier. The access specifier not only determines the part of the program where the member is accessible, but also how it is accessible in the program.


Page 3 of 6

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles