Click here to Skip to main content
15,910,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Moving file with progress Pin
David Crow17-Jul-12 4:26
David Crow17-Jul-12 4:26 
GeneralRe: Moving file with progress Pin
sarfaraznawaz17-Jul-12 20:03
sarfaraznawaz17-Jul-12 20:03 
QuestionRe: Moving file with progress Pin
David Crow18-Jul-12 2:16
David Crow18-Jul-12 2:16 
QuestionAbout opengl screen shot is black Pin
wangningyu16-Jul-12 22:52
wangningyu16-Jul-12 22:52 
SuggestionRe: About opengl screen shot is black Pin
Richard MacCutchan16-Jul-12 23:29
mveRichard MacCutchan16-Jul-12 23:29 
AnswerRe: About opengl screen shot is black Pin
Software_Developer17-Jul-12 3:48
Software_Developer17-Jul-12 3:48 
QuestionBasic / standard MFC VC6.0 CListCtrl questions Pin
Vaclav_16-Jul-12 10:02
Vaclav_16-Jul-12 10:02 
AnswerRe: Basic / standard MFC VC6.0 CListCtrl questions Pin
Jochen Arndt16-Jul-12 21:09
professionalJochen Arndt16-Jul-12 21:09 
GeneralRe: Basic / standard MFC VC6.0 CListCtrl questions Pin
Vaclav_17-Jul-12 3:23
Vaclav_17-Jul-12 3:23 
GeneralRe: Basic / standard MFC VC6.0 CListCtrl questions Pin
Jochen Arndt17-Jul-12 3:33
professionalJochen Arndt17-Jul-12 3:33 
GeneralSOLVED Basic / standard MFC VC6.0 CListCtrl questions Pin
Vaclav_18-Jul-12 3:47
Vaclav_18-Jul-12 3:47 
QuestionCMFCToolbar EnableReflections : how is it supposed to work ? Pin
Maximilien16-Jul-12 9:26
Maximilien16-Jul-12 9:26 
AnswerRe: CMFCToolbar EnableReflections : how is it supposed to work ? Pin
Eugen Podsypalnikov16-Jul-12 23:10
Eugen Podsypalnikov16-Jul-12 23:10 
Questionwhy no virtual constructor? Pin
shanmugarajaa16-Jul-12 3:34
shanmugarajaa16-Jul-12 3:34 
AnswerRe: why no virtual constructor? Pin
sanjaylk16-Jul-12 3:54
sanjaylk16-Jul-12 3:54 
GeneralRe: why no virtual constructor? Pin
Stefan_Lang16-Jul-12 22:07
Stefan_Lang16-Jul-12 22:07 
AnswerRe: why no virtual constructor? PinPopular
jschell16-Jul-12 6:01
jschell16-Jul-12 6:01 
GeneralRe: why no virtual constructor? Pin
Stefan_Lang16-Jul-12 22:08
Stefan_Lang16-Jul-12 22:08 
AnswerRe: why no virtual constructor? Pin
Chris Losinger16-Jul-12 7:02
professionalChris Losinger16-Jul-12 7:02 
AnswerRe: why no virtual constructor? Pin
David Crow16-Jul-12 7:06
David Crow16-Jul-12 7:06 
GeneralRe: why no virtual constructor? Pin
jschell16-Jul-12 10:49
jschell16-Jul-12 10:49 
AnswerRe: why no virtual constructor? Pin
Mattias Högström16-Jul-12 11:34
Mattias Högström16-Jul-12 11:34 
Consider the opposite, that it was possible.

Subclassing, can sometimes be viewed as specialization.
Dog is a specializations of an Animal.
If the Animal has private variables, these are initialized in the constructor.
If the constructor is virtual, it is replaced by a subclass' constructor.
According to the principles of data hiding (public, protected, private), a sub class cannot access private member variables of a parent type. So these member variables would be left uninitialized. You don't want that because the parent class would break.

If you by some reason need a virtual constructor there is a Design Pattern called the Template Method,
http://en.wikipedia.org/wiki/Template_method_pattern

In the example they have they define an algorithm in the parent class,
and let the subclass define the implementation.

It is of course possible to apply the same principle in constructors by creating a virtual method called "Initialize" which you call from the constructor. When this method is redefined in a subclass it will override the parent's definition.

But I have never came across the need for a virtual constructor. Why do you need one?
GeneralRe: why no virtual constructor? Pin
Stefan_Lang16-Jul-12 22:29
Stefan_Lang16-Jul-12 22:29 
GeneralRe: why no virtual constructor? Pin
Mattias Högström17-Jul-12 0:38
Mattias Högström17-Jul-12 0:38 
GeneralRe: why no virtual constructor? Pin
Stefan_Lang17-Jul-12 2:00
Stefan_Lang17-Jul-12 2:00 

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.