Click here to Skip to main content
15,925,440 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionoverloading an overrided function??? Pin
sawerr26-Jul-06 0:25
sawerr26-Jul-06 0:25 
AnswerRe: overloading an overrided function??? Pin
Mike Dimmick26-Jul-06 3:40
Mike Dimmick26-Jul-06 3:40 
AnswerRe: overloading an overrided function??? Pin
Zac Howland26-Jul-06 4:33
Zac Howland26-Jul-06 4:33 
What you are doing is called hiding. The rules the compiler uses for resolving which method you want have problems when you do this. Scott Meyers gives a good explanation of this in his Effective C++ book.

Basically, since char and int can be implicitly casted to each other, your overload hides the method and makes it almost impossible for the compiler to pick the correct method (it is not a mind reader afterall).

To avoid this issue, write code like this instead:

class Base
{
public:
	virtual void func(char n)
	{
		cout << "base" << endl;
	}
};

class Derived : public Base
{
public:
	virtual void func(char c)
	{
		gfunc(9);
	}

	virtual void gfunc(int n)
	{
		cout << "derived" << endl;
	}
};


If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

QuestionHow to access function in different classes Pin
jadhav12326-Jul-06 0:22
jadhav12326-Jul-06 0:22 
AnswerRe: How to access function in different classes Pin
see me26-Jul-06 0:29
see me26-Jul-06 0:29 
GeneralRe: How to access function in different classes Pin
jadhav12326-Jul-06 1:09
jadhav12326-Jul-06 1:09 
AnswerRe: How to access function in different classes Pin
Hamid_RT26-Jul-06 1:25
Hamid_RT26-Jul-06 1:25 
GeneralRe: How to access function in different classes Pin
jadhav12326-Jul-06 1:58
jadhav12326-Jul-06 1:58 
GeneralRe: How to access function in different classes Pin
Hamid_RT26-Jul-06 2:30
Hamid_RT26-Jul-06 2:30 
QuestionHow can I add a button on title bar of a window which is create by other process Pin
Hemant kulkarni25-Jul-06 22:40
Hemant kulkarni25-Jul-06 22:40 
AnswerRe: How can I add a button on title bar of a window which is create by other process Pin
NiceNaidu25-Jul-06 23:16
NiceNaidu25-Jul-06 23:16 
AnswerRe: How can I add a button on title bar of a window which is create by other process [modified] Pin
see me25-Jul-06 23:24
see me25-Jul-06 23:24 
Questiondisplay text transparently by DC Pin
includeh1025-Jul-06 22:31
includeh1025-Jul-06 22:31 
AnswerRe: display text transparently by DC Pin
Arman S.25-Jul-06 22:50
Arman S.25-Jul-06 22:50 
GeneralRe: display text transparently by DC Pin
includeh1026-Jul-06 0:30
includeh1026-Jul-06 0:30 
GeneralRe: display text transparently by DC Pin
Hamid_RT26-Jul-06 1:27
Hamid_RT26-Jul-06 1:27 
AnswerRe: display text transparently by DC Pin
Hamid_RT26-Jul-06 1:21
Hamid_RT26-Jul-06 1:21 
QuestionRuntime DLL calling with any parameters Pin
hunter1325-Jul-06 22:27
hunter1325-Jul-06 22:27 
AnswerRe: Runtime DLL calling with any parameters Pin
Cedric Moonen25-Jul-06 23:00
Cedric Moonen25-Jul-06 23:00 
GeneralRe: Runtime DLL calling with any parameters [modified] Pin
hunter1326-Jul-06 0:42
hunter1326-Jul-06 0:42 
GeneralRe: Runtime DLL calling with any parameters Pin
Cedric Moonen26-Jul-06 1:15
Cedric Moonen26-Jul-06 1:15 
QuestionCAsyncSocket ::OnReceive() missed calls Pin
neilsolent25-Jul-06 21:31
neilsolent25-Jul-06 21:31 
AnswerRe: CAsyncSocket ::OnReceive() missed calls Pin
Steve S25-Jul-06 21:52
Steve S25-Jul-06 21:52 
GeneralRe: CAsyncSocket ::OnReceive() missed calls Pin
neilsolent25-Jul-06 22:57
neilsolent25-Jul-06 22:57 
GeneralRe: CAsyncSocket ::OnReceive() missed calls Pin
Moak4-Oct-06 5:09
Moak4-Oct-06 5:09 

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.