RE: Overloading method in derived class
"Nicolas Romantzoff" <[email protected]>
| Newsgroups | gmane.games.devel.general |
|---|---|
| Message-ID | <[email protected]> |
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 ()
{
Titi titi;
titi.Add(1);
}
And both MSVC 7 and gcc give me
error : 'Titi::Add' : function does not take 1 parameters
sure i could write titi.Toto::Add(1); and this will work but
i want to avoid such a pain.
is it a C++ specification problem or a compiler problem ?
Thanks
------------------------
Lagarde Sébastien
Neko entertainment
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_idU7