A pure virtual function in C++ is
like an "abstract method" in other languages
-- it forces insatiable subclasses to provide an implementation of the
method.
A pure virtual method is an abstract method with no implementation that must be implemented by all subclasses of the owner class. It also refer that the owner class is an abstract class and one can't instantiate an object of it.
class base
{
virtual void show()=0; // pure virtual function
};
class derived : public base
{
void show()
{
cout<<"child class implement pure virtual function";
}
};
void main()
{
derived d;
d.show();
getch();
}
Output: class implement pure virtual function
TCCI Computer Coaching Institute teaches C++ in Bopal and Satellite in Ahmedabad.
Online Coaching is available for any person.
Lecture is conducted as per student flexible time.
Call us @ 9825618292
Visit us @ http://tccicomputercoaching.com/workshop/
A pure virtual method is an abstract method with no implementation that must be implemented by all subclasses of the owner class. It also refer that the owner class is an abstract class and one can't instantiate an object of it.
class base
{
virtual void show()=0; // pure virtual function
};
class derived : public base
{
void show()
{
cout<<"child class implement pure virtual function";
}
};
void main()
{
derived d;
d.show();
getch();
}
Output: class implement pure virtual function
TCCI Computer Coaching Institute teaches C++ in Bopal and Satellite in Ahmedabad.
Online Coaching is available for any person.
Lecture is conducted as per student flexible time.
Call us @ 9825618292
Visit us @ http://tccicomputercoaching.com/workshop/
No comments:
Post a Comment