Can anybody help me with this please?
How can I pass the name from the user input to the constructor ?
Code:#include <iostream> #include <string> using namespace std; class myClass { private: public: myClass() { } myClass(int a) { cout << a << endl; } myClass(string name) { cout << name << endl; } void myfunction() { cout << "something" << endl; } }; int main() { string name; myClass object; object.myClass(); myClass(4); cout << "your name?" << endl; getline(cin, thename); myClass(thename); system("pause"); return 0; }