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 ;

} ;

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers