0

Overloading in C++

can you tell me how to using it "sorry my english is bad"

27th Nov 2016, 11:56 PM
Mr Exs
Mr Exs - avatar
3 ответов
+ 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!
28th Nov 2016, 12:20 AM
NICKALL [EP]
NICKALL [EP] - avatar
+ 1
you can use template class for easy coding
28th Nov 2016, 1:41 AM
Jonathan
+ 1
thank you so much
28th Nov 2016, 1:50 AM
Mr Exs
Mr Exs - avatar