c++ - ERROR: slist was not declared in this scope -
this code isn't working me, getting below-mentioned compilation errors. please me point out mistake.
in function 'int main()': 4:3: error: 'slist' not declared in scope 4:9: error: expected primary-expression before 'int' 5:3: error: 'l' not declared in scope 12:9: error: expected primary-expression before 'int' 13:3: error: 'back' not declared in scope
code:
int main() { slist<int> l; l.push_front(0); l.push_front(1); l.insert_after(l.begin(), 2); copy(l.begin(), l.end(), // output 1 2 0 ostream_iterator<int>(cout, " ")); cout << endl; slist<int>::iterator = l.previous(l.end()); = l.insert_after(back, 3); = l.insert_after(back, 4); = l.insert_after(back, 5); copy(l.begin(), l.end(), // output 1 2 0 3 4 5 ostream_iterator<int>(cout, " ")); cout << endl; }
all problems boil down fact following declaration
slist<int> l;
throwed error that
slist
not declared in scope
you need make sure slist
declared in scope. include
necessary headers.
Comments
Post a Comment