0
Is it possible to have different types of parameters when you use an overload function ?
4 Answers
+ 6
yes you can give different types of parameters to overloaded function like this example
#include <iostream>
// volume of a cube
int volume(const int s)
{ return s*s*s; }
// volume of a cylinder
double volume(const double r, const int h) {
return 3.1415926*r*r*static_cast<double>(h); }
// volume of a cuboid
long volume(const long l, const int b, const int h) { return l*b*h; }
int main() {
std::cout << volume(10);
std::cout << volume(2.5, 8);
std::cout << volume(100, 75, 15);
return 0; }
+ 1
why not
0
all right, thanks a lot :)
0
yes ...you can use different type of parameters or different numbers of parameters in overload function