top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the purpose of abstract class in C++, though we can define the function in each subsequent derived class?

+1 vote
261 views
What is the purpose of abstract class in C++, though we can define the function in each subsequent derived class?
posted Sep 3, 2016 by Ashish Tad

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

When there is no need to create an object or can't create an object from the class definition known as abstract class. This is done only when abstract class is derived from the abstract class. If a class contains at least one pure virtual function, class is considered as an abstract class.
For example: A company developed an abstract class name "bank" and it has a pure virtual function "saving rate" since rate can't be defined unless there is a specific branch object is created. When a bank object such as "sbi", "cbi" , "hdfc" is created and classes of these objects inherited "bank" class and defined "saving rate" method as per their policy.

answer Sep 3, 2016 by Harshita
Similar Questions
+2 votes

I know the definition of singleton class i.e. a class for which only one object can be defined or initialized. But I want to know all the possible ways to achieve this restriction.

...