multiple member function forward declarations

In C++ I can have multiple forward declaration of functions like:

void Func (int);
void Func (int);   // another forward declaration, compiles fine
void Func (int) {} // function definition, compiles fine

And yet VC++ 2010 complains when I do the same for member functions (whether or not I include a definition):

class Test {
   void Func (int);
   void Func (int);   // error C2535 here
   void Func (int) {} // error here too
   };

I couldn't find anything online about multiple member function forward declarations, whether its legal, illegal, VC++ specific, ect... Is there a way around this? Is it illegal?

Now why would I want to do that? No project in particular, was just playing around with different ways to register functions. In other projects I've had to register functions/classes and used less hack-ish but more tedious methods, and was just trying (for fun) different methods using macros/templates.

Any ideas or thoughts? Specifically on the above question, but also on registering functions/classes.

Thanks in advance for your time ;)

9
задан Kaisha 12 May 2011 в 15:24
поделиться