RE: [GD-General] Overloading method in derived class
Brought to you by:
vexxed72
From: Nicolas R. <nic...@fr...> - 2004-02-04 21:17:01
|
Hi, It's neither a C++ spec problem, nor a MSVC compiler problem. It's a wanted C++ spec. for method overriding: Overriding part of overloaded methods hides all other signatures. It allows function call restriction (since class inheritance IS a restriction). You have two choices: Best choice: Add an "inline void Add(int x) { Toto::Add(x); }" line to your Titi definition (overloading the Add operator). Worst choice: Cast your titi in Toto, and call the Add function. Hope this helps. Nicolas -----Original Message----- I have the following code : struct Toto { void Add(int x){} }; struct Titi : public Toto { void Add(int x, int y){} }; int main ()=20 {=20 Titi titi; titi.Add(1); } And both MSVC 7 and gcc give me=20 error : 'Titi::Add' : function does not take 1 parameters sure i could write titi.Toto::Add(1); and this will work but=20 i want to avoid such a pain. is it a C++ specification problem or a compiler problem ? Thanks ------------------------ Lagarde S=E9bastien Neko entertainment |