Click here to Skip to main content
15,929,812 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Virtual constructors... Pin
toxcct15-Nov-05 6:24
toxcct15-Nov-05 6:24 
GeneralRe: Virtual constructors... Pin
Bob Stanneveld15-Nov-05 22:57
Bob Stanneveld15-Nov-05 22:57 
AnswerRe: Virtual constructors... Pin
cmk15-Nov-05 12:23
cmk15-Nov-05 12:23 
QuestionAbstract Base classes vs Interfaces Pin
funwithdolphin15-Nov-05 0:01
funwithdolphin15-Nov-05 0:01 
AnswerRe: Abstract Base classes vs Interfaces Pin
Cedric Moonen15-Nov-05 0:52
Cedric Moonen15-Nov-05 0:52 
AnswerRe: Abstract Base classes vs Interfaces Pin
deardear15-Nov-05 1:00
deardear15-Nov-05 1:00 
AnswerRe: Abstract Base classes vs Interfaces Pin
toxcct15-Nov-05 1:02
toxcct15-Nov-05 1:02 
AnswerRe: Abstract Base classes vs Interfaces Pin
LogiPro10125-Jan-09 11:32
LogiPro10125-Jan-09 11:32 
Difference between Abstract classes and Interface
Little background:
A real world entity is represented in an OOP world as object. Objects are defined as classes any language.
A class defines objects in two aspects
Object's characteristics - Data Members
Object's functionality - Member functions

So, when the classes that are forced to provide implementations of the functions prototypes that are defined in either ‘interfaces’ or a ‘abstract class’ are not belonging to the same family (having some inherited parental characteristics from same parent directly or indirectly) but are rather related through some functionalities then 100% we will go with interface and if above said classes are belonging to same family then we should go with abstract class inheritance.
Also in case of inheritance as everything is a specialization of base parent object so there is allowance of providing some default definitions of the functions that are needed to be implemented further by specialized classes. This is not any way allowed in interfaces because implementing classes are not belonging to same family and are not any way related by characteristics.

An Example:
We have four real world objects:
• Airplane
• Bird
• Sparrow
• Eagle

We have one method that is a functionality of all above objects
• Fly

Now all objects share common functionality flying in air but differ in the mechanism they use to fly.

Also by close look we see that in general there is some common characteristics (as well as some common functionalities) between Sparrow and Eagle that can be a part of common class Bird (that has to be abstract because there is no real thing like bird!). But any way Airplane can't be related to Bird or its specialized classes Sparrow and Eagle.

So if want to expose fly functionality to outer world and want their implementations in Airplane and Sparrow (or any bird), so I will 100% go for Interface and Abstract classes will be a big NO!

But if we exclude Airplane want that fly functionality is exposed to outer world and its implementing classes are Bird, Sparrow and Eagle then 'Abstract Classes' is the best of best choice.

Happy programming! Please feel free in writing to me for further clarifications on other OOP concepts (im.himanshu2006@gmail.com)

Himanshu Smile | :)
QuestionBuiding dll with Visual Studio 2003 Pin
Emb_Emb14-Nov-05 23:42
Emb_Emb14-Nov-05 23:42 
QuestionEasy installation of printer drivers Pin
Palani Surendrnath14-Nov-05 23:40
Palani Surendrnath14-Nov-05 23:40 
AnswerRe: Easy installation of printer drivers Pin
toxcct15-Nov-05 0:13
toxcct15-Nov-05 0:13 
QuestionActiveX control without parent container Pin
Ahsan Askare14-Nov-05 23:35
Ahsan Askare14-Nov-05 23:35 
QuestionEasy installation of printer drivers Pin
Palani Surendrnath14-Nov-05 23:23
Palani Surendrnath14-Nov-05 23:23 
Questionwstring to LPCTSTR Pin
Luke Murray14-Nov-05 22:54
Luke Murray14-Nov-05 22:54 
AnswerRe: wstring to LPCTSTR Pin
kakan15-Nov-05 0:07
professionalkakan15-Nov-05 0:07 
GeneralRe: wstring to LPCTSTR Pin
Luke Murray15-Nov-05 12:44
Luke Murray15-Nov-05 12:44 
AnswerRe: wstring to LPCTSTR Pin
22491715-Nov-05 1:56
22491715-Nov-05 1:56 
GeneralRe: wstring to LPCTSTR Pin
sunit515-Nov-05 2:21
sunit515-Nov-05 2:21 
GeneralRe: wstring to LPCTSTR Pin
toxcct15-Nov-05 2:43
toxcct15-Nov-05 2:43 
GeneralRe: wstring to LPCTSTR Pin
22491715-Nov-05 5:44
22491715-Nov-05 5:44 
GeneralRe: wstring to LPCTSTR Pin
Luke Murray15-Nov-05 12:42
Luke Murray15-Nov-05 12:42 
GeneralRe: wstring to LPCTSTR Pin
22491715-Nov-05 17:16
22491715-Nov-05 17:16 
GeneralRe: wstring to LPCTSTR Pin
sunit515-Nov-05 19:03
sunit515-Nov-05 19:03 
GeneralRe: wstring to LPCTSTR Pin
Luke Murray15-Nov-05 20:41
Luke Murray15-Nov-05 20:41 
Questionstruct inadvertantly calling stdafx.h function Pin
newbie534514-Nov-05 22:45
newbie534514-Nov-05 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.