int main() { /* In C++, unlike in C, definitions can omit argument names if they don't use those arguments! This probably exists for method overridding. */ { assert(def_no_argname(0) == 1); assert(def_no_argname(0, 0) == 2); } }
int main() { // # Overload { assert(overload(1) == "i"); //base type conversions { assert(overload(1.0f) == "f"); /* ERROR: ambiguous overload(int) overload(float) Compiler does not know wether convert double to float or int. */ //overload(1.0); } /* ERROR: ambiguous should compiler coverts to Base or BaseProtected? Both are possible via the default copy constructors. */ { Class cOverload; //overloadBase(cOverload); } // ERROR: ambiguous //i=4; //overloadValAddr(i); /* # volatile overload Functions that differ by `volatile` can be overloaded: - http://stackoverflow.com/questions/10242578/volatile-overloading */ {} /* Function pointer: decided by the typecast. http://stackoverflow.com/questions/2942426/how-to-specify-a-pointer-to-an-overloaded-function */ { // Variable. { std::string (*fi)(int) = overload; std::string (*ff)(float) = overload; } } } /* In C++, unlike in C, definitions can omit argument names if they don't use those arguments! This probably exists for method overridding. */ { assert(def_no_argname(0) == 1); assert(def_no_argname(0, 0) == 2); } }