overload c++ duty according relapse value
we know profusion duty according parameters:
int mul(int i, int j) { relapse i*j; }
std::string mul(char c, int n) { relapse std::string(n, c); }
can profusion duty according relapse value? interpretation duty advantage opposite things according relapse value used:
int n = mul(6, 3); // n = 18
std::string s = mul(6, 3); // s = "666"
// note both invocations take accurate same parameters (same types)
you assume initial parameter between 0-9, need establish quarrel have any blunder handling.
Comments
Post a Comment