Definition of Polymorphism in C++ with example.
The basic definition of polymorphism in C++ is
Polymorphism is the property by which the message can be sent to objects of several different classes , and each can respond to it in a different way depending upon its class. In C++ Polymorphism is itemplemend through the basic concept called as overloading.
Example of polymorphism
float a ( float b)
{
return b*b;
}
float a ( float b, float c)
{
return b*c;
}
Inheritance in C++ with Example.
Inheritance in C++ is basically the capability of one class to inherit properties from another class . For example , house is a class wherefrom class chiarhouse inherits as given below:
class house
{
protected:
char name[25];
int rollno;
public:
void readhouse ();
void showhouse ();
};
class chairhouse: protected house
{
protected :
char tables[50];
public:
void readchahou();
void showchahou();
};
Advantages of OOP in C++.
The Basic advantages of OOPs in C++ are
1.Reusability of code
2. Ease of comprehension
3. Ease of Fabrication and Maintenance .
4. Easy redesign and extension
Objects implemented in the C++.
The basic details like the object implemented in C++ as in terms of the software are
1. Characteristics/attributes are implemented through member variables or from the data items of the object.
2. Behaviour is also implemented through member functions called methods.
3. It is always given a unique name to give its identification.
An Object and a Class in C++
The basic difference Between the Object and a Class in a C++ program is
Object
An object is basically an identifiable entity with some characteristics and behaviour.
It also behaves as an entity that has the ability to store data and its associated functions.
Class
A class in a C++ is basically a group of objects that share common properties and relationships.
And in another way can be said as a group of similar objects.
Object Oriented Programming and Procedural Programming in C++
The Basic Difference Between the Object Oriented Programming and Procedural Programming in C++ Is
Object Oriented Programming
1. Here the basic focus is on Objects.
2. This follows a Bottom - up approach in a program.
3.It's ability of data hiding feature prevents the accidental change in data.
4. The basic features of this type are data encapsulation,polymorphism and inheritence.