Explain Abstract Class in C++

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 ;

} ;

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>