=== [[C++]] [[OOP]]=== /** @author: http://www.rzr.online.fr * How comes typed function overloading break it all ? */ #include using namespace std; #define CONFLICT // choose one of these not CONFLICT + OVERLOAD #define OVERLOAD class Base { public: virtual void main() { fvirtual(); } // show polymorphism virtual void fvirtual( std::ostream & out = std::cout ) { out<<"Base::fvirtual"<main(); // ok it is allways linked c->fvirtual( argv[[0]] , std::cout); // will cause an error on compilation return 0; } /* TARGET=cpppolymorphismdefaultparm CXXFLAGS="-g -Wall -DMAIN_${TARGET}" make ${TARGET} CXXFLAGS="${CXXFLAGS}" \ && ${TARGET} || gdb ${TARGET} */ irc://irc.freenode.net/#c++ helped : RzR: function lookup and overload resolution are two distinct steps, performed in sequence. in short, the fvirtual(char*... ) becomes hidden in Derived. just because it has the same name ? thats annoying yes, having the same name is called overloading.... hiding rule when you override one overloaded version, you'll have to override them all. the mangled name is different , isnt it ? i thought that parameters where also defining a method c++ has no concept of mangling names, only the implementations have... ok well it makes sense now so it is tricky to use generic names for functions Leave comments here http://rafb.net/paste/results/rnWx7p69.html