Polymorphism in C++

Polymorphism is about a same piece of code behaves differently in different situations. In C++, polymorphism is achieved by function overloading, operator overloading, and virtual function overriding. Same interface, function or operation, can be bound to different object types, hence, different behaviors. Binding can happen compile time or runtime. Base on that polymorphism is categorized … Continue reading “Polymorphism in C++”

Inheritance in C++

In Object Oriented Programming, inheritance is a mechanism of acquiring properties and behaviors in one class from another. In C++, one class can be derived from another class which is called base class. The derived class is often referred as a ‘child‘ class and the base one as ‘parent‘ class. It is like, the ‘child‘ … Continue reading “Inheritance in C++”

Friend Class in C++

The private and protected class members are not allowed to be accessed from outside the class. Only inherited or derived classes can access the protected members of its parent or base class. No other class or function can access them. But a friend class can access the private and protected members of a class where … Continue reading “Friend Class in C++”

Friend Function in C++

Private and protected class members are not allowed be accessed from outside the class. We can access the private members only from the same class, whereas, the protected members can be accessed from the same class and from its derived classes. But a friend function can access the private and protected members of the granting … Continue reading “Friend Function in C++”

Method Chaining in C++

Method chaining is a mechanism of calling multiple functions (methods) in a single statement. It helps us reduce number of lines in the code and increase code elegancy. And in most cases it increases the code readability. Here in the class, c1, we have 3 member functions. First two functions set two variables – x … Continue reading “Method Chaining in C++”

0
0
0
0
0
0