Problem with stl list
I made a little program to parse string, but my compiler gives me a mistake. And I don't know what have I done wrong. Please help!
using namespace std;
ll = new list<string>;
string str = "1+2+3";
for(int i = 0; i<5; i++)
myList.ll.push_back(i); //compiler gives a mistake here
C++ is neither C# nor Java. So this syntax
std::list<std::string> ll = new std::list<std::string>;
is invalid in C++.
By the way we are not compilers that to search errors in your code. If your compiler issued an error then post it here.
As I understood my constructor
ll = new list<string>; is wrong... Could somebody explain how it should be?
std::list<std::string> ll; //done, list created
When an object of your class is being created then constructors of its members are called. Class std::list has a default constructor that will be called.
Topic archived. No new replies allowed.