I'm new to the std vector class, and recently implimented a class structure similar to the one in the program below. When I received an "Access Violation" error when trying to push something into the vector, I recreated the problem in a simpler program (show below). I'm assuming that the vector has no room to grow within a structure and causing an error message, but am not sure how the vector actually works. If that is the case, I would greatly appreciate a suggestion on how to use an alternative method of achieving a similar system using the vector class. I'm hoping that I'm just using it wrong though.
please help me!Code:#include <vector> using namespace std; struct s{ vector<int> v; }; int main(){ vector<s> db; s ns; db.push_back(ns); s *p = db.end(); p->v.push_back(4); return 0; }![]()



LinkBack URL
About LinkBacks



