简体   繁体   中英

why the getline function isn't recognizing it as a string?

There is a pointer struct named children, and within it there are these two pointers, name and age.

employees[i].children[j].name = new string();
employees[i].children[j].age = new int[1];
cout << "WRITE THE NAME OF THE DEPENDENT " << j+1 << endl;
getline(cin,employees[i].children[j].name);

This is giving me this error: no matching function for call to 'getline(std::istream&, std::string*&)'

The name field is a pointer to a string. You need to use:

getline(cin,*(employees[i].children[j].name));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM