0
Overloading in C++
can you tell me how to using it "sorry my english is bad"
3 odpowiedzi
+ 2
to overload a method in c++ first define a method with the same access modifier and name as another. then to overload the previous method change the number of parameters or the type of parameters. for example:
public int returnNum(int x) {
return x;
}
public float returnNum(float x) {
return x;
}
in main we can do the following:
returnNum(6);
returnNum(6.666);
now the method (or in this case function) works for floats and integers.
Hope this helped you!
+ 1
you can use template class for easy coding
+ 1
thank you so much