[英]C++ Linked List Push_back ERROR
Getting error 遇到错误
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>]
trying to push a .text file using argument into list however it wont push code is below 尝试将使用参数的.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;
}
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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.