Constructor: different parameter type
#include <iostream> #include <cstdlib> using namespace std; class myclass { int a; public: myclass(int x) { a = x; } myclass(char *str) { a = atoi(str); } int geta() { return a; } }; int main() { myclass object1 = 4; myclass object2 = "123"; cout << "object1: " << object1.geta() << endl; cout << "object2: " << object2.geta() << endl; return 0; }