I am trying out simple class and linked list implementation.
Please help me out with this code as i am receiving
"list iterator not dereferencable"
when running the code.
using namespace std;
void getType(string x)
type = x;
list<Car>::iterator curr = c.begin();
cout << "Please key in anything you want: ";
cout << "The phrase you have typed is: " << curr->showType() << endl;
Write the following way
cout << "Please key in anything you want: "; getline(cin, p); c.push_back( Car() ); list<Car>::iterator curr = c.begin(); curr->getType(p);
And it is much better to rename the member function
Take into account that the function main without parameters shall be declared like
int main() ^^^