In a project i want to retu a locally created list to the calling function.The code is:
Product product;
std::list<Product>::iterator iter;
int i = 0;
while (i<3){ //statically given value=3
input.read((char*)&product, sizeof(product));
Productlist.push_back(product);
i++;
}
iter = Productlist.begin();
cout << iter->GetProduct_no() << " " << iter->GetProduct_name() << endl; //just for testing purpose.
iter++;
input.close();
retu Productlist; //exception here:Access Violation;
}
The list values are getting displayed correctly but the program ends throwing an exceptoin stated above while retuing the list.
