#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Function overloading - example
class Print {
public:
void show(int x) {
cout << "int : "<< x << endl;
}
void show(string str) {
cout << "str: " << str << endl;
}
void show(string str2) { // <--- This is the problem ( can't put two functions
under a class when it comes to function overloading....
cout << "str2: " << str2 << endl;
}
};
int main() {
Print ob1;
ob1.show(45);
ob1.show("apna college");
ob1.show("Debadatta Patra");
return 0;
}
No comments:
Post a Comment