Click here to Skip to main content
15,920,503 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: to link MDI interface to a dialog Pin
Nibu babu thomas1-Mar-06 16:49
Nibu babu thomas1-Mar-06 16:49 
QuestionUsing Sockets in Win32 DLL Pin
castratroi28-Feb-06 21:03
castratroi28-Feb-06 21:03 
Questionvirtual function declarations Pin
lastgen28-Feb-06 20:45
lastgen28-Feb-06 20:45 
AnswerRe: virtual function declarations Pin
lastgen28-Feb-06 20:55
lastgen28-Feb-06 20:55 
GeneralRe: virtual function declarations Pin
Cedric Moonen28-Feb-06 20:58
Cedric Moonen28-Feb-06 20:58 
AnswerRe: virtual function declarations Pin
Cedric Moonen28-Feb-06 20:57
Cedric Moonen28-Feb-06 20:57 
AnswerRe: virtual function declarations Pin
Nibu babu thomas28-Feb-06 20:57
Nibu babu thomas28-Feb-06 20:57 
AnswerRe: virtual function declarations Pin
John R. Shaw28-Feb-06 23:03
John R. Shaw28-Feb-06 23:03 
I am making an assumption that you did not define the function in the original class and that the second version worked. If you had defined the function (or method) in the first class you would not have had an error. Your could have simply declared it as this virtual void FOO (BAR& foo) {}; and there would not have been an error, you would have just had a function that did not do anything.

The second version declares a pure virtual function, which needs to be implemented by a derived class. That is you inherited the interface from the defined base class (ABC) and must provide a function for the inherited interface. What that means is in the base class you have said this function must exit in the derived class, because it does not actually exist in the base class.

Let’s try this,
If you declare a function in a class the compiler will complain if that function does not exist. Therefore you must define the function so any one using that class will have that function to call. If you make the function as a pure virtual function, then the class is designed as a base interface class that is not intended to be used by its self, but is intended to be used as a base for derived classes.

I know I sound like some text book, but I have been doing this a long time. Look up the words “pure virtual” and “virtual base class” along with “C++” on the Web; you should come up with a few decryptions. Amongst those may be instrument and car, all cars have things in common like press the accelerator, press the brake, and ect… . The base class specifies all things that classes derived from it have in common and forces all derived classes to implement those behaviors.

Think of the “= 0” as a requirement that you impose on all users of the class that you have defined.

I hope that helps,
John R. Shaw


INTP
Every thing is relative...
QuestionC++ Pin
yaaqub28-Feb-06 20:04
yaaqub28-Feb-06 20:04 
AnswerRe: C++ Pin
Nibu babu thomas28-Feb-06 20:10
Nibu babu thomas28-Feb-06 20:10 
AnswerRe: C++ Pin
Ryan Binns28-Feb-06 20:11
Ryan Binns28-Feb-06 20:11 
AnswerRe: C++ Pin
_AnsHUMAN_ 28-Feb-06 21:25
_AnsHUMAN_ 28-Feb-06 21:25 
GeneralRe: C++ Pin
David Crow1-Mar-06 3:18
David Crow1-Mar-06 3:18 
GeneralRe: C++ Pin
_AnsHUMAN_ 1-Mar-06 5:03
_AnsHUMAN_ 1-Mar-06 5:03 
GeneralRe: C++ Pin
David Crow1-Mar-06 6:39
David Crow1-Mar-06 6:39 
QuestionIncremental backup of a disk. Pin
ashtwin28-Feb-06 19:36
ashtwin28-Feb-06 19:36 
AnswerRe: Incremental backup of a disk. Pin
David Crow1-Mar-06 3:20
David Crow1-Mar-06 3:20 
Questioncopy file to URL Pin
Anilkumar K V28-Feb-06 19:19
Anilkumar K V28-Feb-06 19:19 
AnswerRe: copy file to URL Pin
vivek.s.vivek28-Feb-06 20:10
vivek.s.vivek28-Feb-06 20:10 
AnswerRe: copy file to URL Pin
David Crow1-Mar-06 3:22
David Crow1-Mar-06 3:22 
QuestionHow to hide standard toolbar in my simple appliation by default? Pin
G Haranadh28-Feb-06 19:05
G Haranadh28-Feb-06 19:05 
AnswerRe: How to hide standard toolbar in my simple appliation by default? Pin
Nibu babu thomas28-Feb-06 19:16
Nibu babu thomas28-Feb-06 19:16 
GeneralRe: How to hide standard toolbar in my simple appliation by default? Pin
G Haranadh28-Feb-06 19:49
G Haranadh28-Feb-06 19:49 
AnswerRe: How to hide standard toolbar in my simple appliation by default? Pin
Cool Ju28-Feb-06 19:47
Cool Ju28-Feb-06 19:47 
QuestionMovePrev() can't works Pin
mikobi28-Feb-06 18:57
mikobi28-Feb-06 18:57 

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.