Click here to Skip to main content
16,007,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: XP Buttons on non grey backgrounds Pin
Jörgen Sigvardsson10-May-05 1:58
Jörgen Sigvardsson10-May-05 1:58 
GeneralRe: XP Buttons on non grey backgrounds Pin
khan++10-May-05 2:27
khan++10-May-05 2:27 
GeneralRe: XP Buttons on non grey backgrounds Pin
Jörgen Sigvardsson10-May-05 2:49
Jörgen Sigvardsson10-May-05 2:49 
GeneralRe: XP Buttons on non grey backgrounds Pin
Jörgen Sigvardsson10-May-05 3:06
Jörgen Sigvardsson10-May-05 3:06 
Generalrecv problem Pin
srev10-May-05 1:26
srev10-May-05 1:26 
GeneralVirtual function problem! Pin
Bob Stanneveld10-May-05 0:11
Bob Stanneveld10-May-05 0:11 
GeneralRe: Virtual function problem! Pin
Cedric Moonen10-May-05 0:28
Cedric Moonen10-May-05 0:28 
GeneralRe: Virtual function problem! Pin
Bob Stanneveld10-May-05 1:09
Bob Stanneveld10-May-05 1:09 
cedric moonen wrote:
Virtual functions are used like in the following case:

CBase* pClass = new CDerived;
pClass->Foo();


No, the purpose of virtual functions is that the correct function is called when the exact type of a class is not known. For exemple:
<br />
class A<br />
{ <br />
public:<br />
virtual void Foo() {}<br />
};<br />
<br />
class B<br />
{<br />
public:<br />
virtual void Foo() {}<br />
};<br />
<br />
A* pA = new B;<br />
pA->Foo(); // calls B::Foo<br />


cedric moonen wrote:
In this case, the function that will be called is the derived function. The thing I don't understand is why do you want to call the redifined Foo function from within the base class ???

The base class (the interface) relies on functionality that cannot be implemented at that level, but the general functionality is always the same...

So the user must supply some functionality that is different for each use of the class.

cedric moonen wrote:
Why not simply call the Foo function directly ?

What do you mean by that, calling the function directly. If you mean that I should cast to the derived type, I cannot. This is because I don't know which one of the infinitly amount of possible derived classes would be calling the function.

cedric moonen wrote:
Maybe because you want this function to do something common for every class ? But then a much better solution would be to call from within your redifined Foo function a function from the base class.
In the most cases this would be the better solution, but in my particular case, it requires more than just 2 lines of code that will need to be rewritten every time a new class is derived from the base class.

I have a couple of dozen lines that are identical for every case, but the implementation of a function in the middle of those lines is user specific. I need to call that function from the base class, because I cannot rely on the end user to execute certain code before and after the call. Besides that, I don't want the user to write all those lines over and over again...




I also got the blogging virus..[^]
GeneralRe: Virtual function problem! Pin
Cedric Moonen10-May-05 1:34
Cedric Moonen10-May-05 1:34 
GeneralRe: Virtual function problem! Pin
S. Senthil Kumar10-May-05 1:43
S. Senthil Kumar10-May-05 1:43 
GeneralRe: Virtual function problem! Pin
Cedric Moonen10-May-05 2:01
Cedric Moonen10-May-05 2:01 
GeneralRe: Virtual function problem! Pin
S. Senthil Kumar10-May-05 2:14
S. Senthil Kumar10-May-05 2:14 
GeneralRe: Virtual function problem! Pin
Tim Smith12-May-05 4:01
Tim Smith12-May-05 4:01 
GeneralRe: Virtual function problem! Pin
S. Senthil Kumar10-May-05 1:10
S. Senthil Kumar10-May-05 1:10 
GeneralRe: Virtual function problem! Pin
Bob Stanneveld10-May-05 1:14
Bob Stanneveld10-May-05 1:14 
GeneralRe: Virtual function problem! Pin
S. Senthil Kumar10-May-05 1:19
S. Senthil Kumar10-May-05 1:19 
GeneralRe: Virtual function problem! Pin
Bob Stanneveld10-May-05 1:51
Bob Stanneveld10-May-05 1:51 
GeneralRe: Virtual function problem! Pin
S. Senthil Kumar10-May-05 2:05
S. Senthil Kumar10-May-05 2:05 
GeneralRe: Virtual function problem! Pin
Bob Stanneveld10-May-05 2:15
Bob Stanneveld10-May-05 2:15 
GeneralRe: Virtual function problem! Pin
S. Senthil Kumar10-May-05 2:20
S. Senthil Kumar10-May-05 2:20 
GeneralRe: Virtual function problem! Pin
Bob Stanneveld10-May-05 3:07
Bob Stanneveld10-May-05 3:07 
Generalwhat's the use of adding __declspec(uuid(&quot;.....&quot;)) in a struct Pin
HeartFriend10-May-05 0:08
HeartFriend10-May-05 0:08 
GeneralRe: what's the use of adding __declspec(uuid(&quot;.....&quot;)) in a struct Pin
ThatsAlok10-May-05 1:06
ThatsAlok10-May-05 1:06 
GeneralRe: what's the use of adding __declspec(uuid(&quot;.....&quot;)) in a struct Pin
HeartFriend10-May-05 15:35
HeartFriend10-May-05 15:35 
GeneralRe: what's the use of adding __declspec(uuid(&quot;.....&quot;)) in a struct Pin
ThatsAlok10-May-05 22:41
ThatsAlok10-May-05 22:41 

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.