I am trying to resize vector defined over a defined custom class
class Product{
private:
Product *next;
int pid;
public:
Product(int _pid): pid(_pid){}
};
int main(){
vector<Product> v;
v.resize(1, Product(1));
v[1] = Product(1);
v.resize(2, Product(2));
}
My code is failing when i try to resize it second time, I have looked over other answers but I couldn't really get the idea behind it.
I have a requirement where I need to resize the vector.
Could someone please explain it and any workaround for it?
Aucun commentaire:
Enregistrer un commentaire