C++链表推送错误
获取错误C++链表推送错误,c++,list,C++,List,获取错误 tryout.cpp:29: error: no matching function for call to 'std::list<char, std::allocator<char> >::push_back(std::string&)'/opt/csw/gcc4/lib/gcc/sparc-sunsolaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/stl_list.h:773: note: can
tryout.cpp:29: error: no matching function for call to 'std::list<char, std::allocator<char> >::push_back(std::string&)'/opt/csw/gcc4/lib/gcc/sparc-sunsolaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/stl_list.h:773: note: candidates are: void std::list<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = char, _Alloc = std::allocator<char>]
试图使用参数将.text文件推送到列表中,但无法推送
代码如下
int main (int argc, char* argv[])
{
string vowels;
list<string> myList;
ifstream infile(argv[1]);
//open the file
if (infile.is_open() && infile.good()) {
while (infile.get(vowels))) {
myList.push_back(vowels));
infile.close();
return 0;
}
首先清除混乱。此外,由于懒惰,您的测试用例缺少一些头和一些std::实际错误是:没有匹配的函数用于调用“std::basic\u ifstream::getstd::string&”
int main(int argc, char* argv[]){
char vowels;
list<char> myList;
ifstream infile(argv[1]);
if (infile.is_open() && infile.good()) {
while (infile.get(vowels)) myList.push_back(vowels);
infile.close();
}
return 0;
}