为什么getline函数没有将它识别为字符串?

时间:2015-09-12 01:27:10

标签: c++ memory-management getline

有一个名为children的指针结构,其中有两个指针,名称和年龄。

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);

这给了我这个错误:没有匹配函数来调用'getline(std :: istream&amp;,std :: string *&amp;)'

1 个答案:

答案 0 :(得分:0)

<dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.joda</groupId> <artifactId>com.springsource.org.joda.time</artifactId> <version>1.6.0</version> <scope>compile</scope> </dependency> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>${bundle-plugin.version}</version> <extensions>true</extensions> <configuration> <instructions> <_failok>true</_failok> ... <Export-Package>org.joda.time*</Export-Package> <Embed-Dependency>*;scope=compile</Embed-Dependency> ... </instructions> </configuration> </plugin> 字段是指向字符串的指针。你需要使用:

name