Home / Tips / C++ Tips / C++: Abstract Classes

“Chishiki” is Japanese for “knowledge.” e-chishiki.com aims to bring software developers, information security professionals, IT executives and other IT pros a rich body of knowledge in the form of articles, interviews, tutorials and technical discussions. Our contributors are among the biggest names in the Indian IT industry and include noted authors, educators and practitioners.

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.

On Sale From April 2008

Let Us C
8th Ed.
C programming classic & best seller. 1 million+ copies sold!

Y. Kanetkar

On Sale From April 2008

Introduction to Object Oriented Programming & C++

Y. Kanetkar

On Sale From Fall 2008

Microsoft .NET Framework: Web Application Security

Vijay Mukhi

On Sale From Nolvember 2008

Quest C++ Courseware
12+ hours of instructional audio and animated slides.

Y. Kanetkar Asang Dani

On Sale From November 2008

A Programmer's Guide to Web Application Security

Vijay Mukhi

Latest Forum Posts