[C++-sig] Overloads.html
William Trenker
wtrenker at hotmail.com
Mon Dec 16 03:59:30 CET 2002
It would be really helpful if the example in overloads.html included a
second, overloaded definition of the member function f().
I tried adding another "f" member function as follows (notice that I made
the number of arguments the same):
...
struct X
{
Y& f(int x, double y = 4.25, char const* z = "wow")
{
return inner;
}
int f(int x, int y, int z) { return x + y + z; }; //another f with 3
args
Y inner;
};
...
Of course what also needs to be shown are the modifications to the
class_<>.def's in this extended example. (If I understand the relevent
discussion in the mailing list, there has to be a properly type-coerced
class_<>.def() for each overloaded variant of f().)
Can someone post the completed example with this additional f() member fully
implemented?
Another useful example would be where the overloaded function also involves
a base class; perhaps a "struct Z : public X" where Z has yet another
version of f(), also with 3 arguments. And to cover all the bases, how about
including an override of a member function that has the same signature as a
member function in the base class, sort of like this:
Struct Z : public X {
void f(void*, char*, double); //yet another signature
int f(int x, int y, int z); //overrides an identical signature in the
base class
};
My interest in these clarifications is practical; the FLTK GUI I am
attempting to wrap is full of overloads and sub-classes.
Thanks,
Bill
ps: In overloads.html, the line of code reading "stryct Y {};" needs
changing to "struct Y {};".
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
More information about the Cplusplus-sig
mailing list