C++: Abstract Classes
Abstract Classes
Abstract classes are commonly used in COM technology to design Interfaces.
A class with a pure virtual function is known as an abstract class. We cannot create an object of such a class. It is implemented as follows:
class myclass
{
virtual void fun1( ) = 0 ;
void fun2( )
{
cout << "In fun2" ;
}
} ;
Generally, an abstract class is created when the designer of the class wants it to be inherited by the other programmer. The main use of an abstract class is to provide a standard interface for derived classes. The pure virtual function is left to be implemented by the derived classes.
A class with only pure virtual functions is known as pure abstract class. It is implemented as follows:
class myclass
{
virtual void fun1( ) = 0 ;
virtual void fun2( ) = 0 ;
} ;




Comments
Log in or create a user account to comment.