Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ oops OOP
When I use abstract classes? How do I make a concrete class abstract?
Posted 21-Aug-12 2:27am
Jon_adam1.2K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Abstract classes are mainly used for specify interfaces (interface is a basic OOP concept, make sure to grasp it).
You transform a concrete class into an abstract one simply adding to it a pure virtual method (or changing an existing method to pure virtual), e.g.
// 'Concrete' Foo
class Foo
{
  //... Foo definition
};
 

// 'Abstract' Foo
class Foo
{
  //... Foo definition
  virtual do_something()=0;
};
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

An abstract class in C++ contains at least one pure virtual function which is a function defined as:
virtual void foo() = 0;
.
The important part here is the "= 0" statement.
 
If you inherit from an abstract class you'll have to provide function definitions for every inherited pure virtual function. Otherwise it is not possible to create an instance of the derived class. Hence in terms of C++ it is not possible to instantiate abstract classes.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Answer to your first question:-
 
19,000,000 results for when to use an abstract class
 
Now, why do you require to make a concrete class abstract? As:-
 
http://www.brpreiss.com/books/opus4/html/page611.html
 
I hope this will clear out your confusion.
 
Thanks
  Permalink  
Comments
Jaims2 at 21-Aug-12 8:10am
   
thanks,I am a beginner in programming
Varun Sareen at 21-Aug-12 10:34am
   
your welcome dear
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

abstract class is base class for define other classes ex: team is developing graphics application and team is designing Line and Circle class but it is necessary both class have method with the conman name in this case team lead define an abstract class name Graphics and ask developer to derive class from the Graphics.
 
Abstract class dose not have method body it provide empty implementation of method but after deriving this class to other class developer has to override methods define in the base class in this way developer will develop the derived classes with the same method name as define in abstract class
 
concrete class is class which is derive from abstract class.
I don't know how to define concrete class abstract class
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 21 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100