I'm trying to get user input for a string pointer in my code within a constructor. My actual pointer was created in my class.
When I try it this way, nothing gets stored.
UserInfo::UserInfo()
{
cout << "Please enter your PhoneNumber: ";
cin >> phoneNum;
cout << "Please enter your name: ";
name = new string();
getline(cin, *name);
assert(name != NULL);
cin.ignore(80, '\n');
}
I've also tried to do it this way:
name = new string(getline(cin,*name));
But, that doesn't work either.