C++ member function overloading picks wrong function -


msvc throws error c2660 when trying overload global function member function (with different number of arguments) calls global function in it's body.

this code:

void f(int* x, int y) { *x += y; }  struct {     int* x;     inline void f(int y)     {         f(x, y); // tries call a::f instead of f     }      void u(void)     {         f(5);     } }; 

gives error:

error c2660: 'a::f' : function not take 2 arguments 

use ::f(x, y); use 1 in global namespace.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -