Polymorphism in C++ programming is an important concept of OOP. When we have many classes that are related to each other by inheritance and more than one form of a class.
#include<iostream.h>
#include<conio.h>
class cls
{
public:
get()
{
cout<<"This is get() function"<<endl;
}
show()
{
cout<<"This is show() function"<<endl;
}
};
void main()
{
cls *obj; //pointer 'obj' is object of Class 'cls'.
obj->get(); //calling 'get()' function.
obj->show(); //calling 'show()' function.
getch();
}
#include<iostream.h>
#include<conio.h>
namespace first_space //'first_space' is name of Name Space.
{
void func()
{
cout<<"Inside first_space"<<endl;
}
}
namespace second_space //'second_space' is name of Name Space.
{
void func2()
{
cout<<"Inside second_space"<<endl;
}
}
void main()
{
first_space::func(); //Calls function'func()' from first name space.
second_space::func2(); //Calls function'func2()' from second name space.
getch();
}