Virtual Base Class in C++

In a C++ programming language to overcome the ambiguity problem occurred due to multipath inheritance we use “virtual” keyword. By using the “virtual” keyword we can declares the specified class virtual.  When a class declared as virtual, then the compiler takes necessary precaution to avoid the duplication of member variable. We can make a class … Read more

Categories C++

Inheritance and types of Inheritance in C++

Inheritance is a one of the most important feature of object oriented programming. Inheritance allow an object of one class to acquire the properties of another object of another class. It supports the reusability and support hierarchical classification.  The class which inherits the another class is called derived class and the class which inherited is … Read more

Categories C++

Operator Overloding in C++

In a C++ language, operator overloading is one of the  important feature of c++.   It is an example of polymorphism. Polymorphism means one function having many forms .   There are different operators we use in a traditional programming  language the operator such as +,-,*,/ etc. For example: +( plus ) operator is used to … Read more

Categories C++

Local vs Global Object in C++

In the C++ language generally, we create an object of the class in a main() function or member function but it is also possible to create an object globally. Such objects are called global objects. Example: Write a C++ program to show the difference between the local and global objects.

Output

Read More … Read more

Categories C++

Destructors in C++

In a C++ Programming, Destructor is also a special member like constructor. Like a constructor, destructor have the same name as their class , preceded by a tilde(~). Destructor does not have a return type means it cant return any value. Destructor destroys the class object created by constructor. It is automatically called when object … Read more

Categories C++

Constructor in C++

Constructor is similar to function that has a same name as the class in which it is resides . Constructor  is automatically called when the object of that class created in which it is resides. A class can contains more than one constructor. Constructor does not have a return value. Characteristics of constructor Constructor has … Read more

Categories C++

Function Overloading in C++

  In C++  language, we can use create a more than one function with same name but each function must have different parameter list. Such functions are called overloaded function and this process is known as function overloading. Function overloading is an example of polymorphism. Polymorphism means one function having many forms .    Example … Read more

Categories C++

Local and Nested Classes in C++

In a C++ language we can define a class within a function and such class are called local class. Inside the local class we can access global and static variable. Local class can’t access the normal/non static variable of function.

Output

Description: In the above program, class B is defined within main() function … Read more

Categories C++

Friend Function in C++

In a C++ programming language private member of the class can accessed by member function. Any non-member function can’t access private data member of the class. But if we want to access the private data in non member function it is still possible by using the “friend function”. A friend function can access private data … Read more

Categories C++

Array of Object in C++

As we know array is a collection of similar data elements. We can also create array of object. Que. WAP to create a array of object. initialize and display the content of array.   OR  WAP  to create a class player and take a details from user name, age and print. Also use  array of object. … Read more

Categories C++