0

What is the overloading functions

with examples

23rd Apr 2017, 6:27 PM
taha khan
taha khan - avatar
3 Antworten
+ 4
So C++ allows you to give your function more than one definition of itself. Like this: #include <iostream> using namespace std; class printData { public: void print(int w) { cout << "This is an integer: " << w << endl; } void print(char* c) { cout << "This is a character: " << c << endl; } }; int main(void) { printData p; p.print(5); // prints out --> This is an integer: 5 p.print("Hello, world!"); // prints out --> This is a character: Hello, world! return 0; }
23rd Apr 2017, 6:44 PM
inactive
+ 4
In object oriented programming you can overload a method ( function). I'ts usefull to create a consistent and clean semantic to build your application. Example: teacher.update(name) teacher.update(age) assuming that name is a string, and age is an integer
23rd Apr 2017, 6:55 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
+ 1
thankx
23rd Apr 2017, 6:44 PM
taha khan
taha khan - avatar