I need your advice on how to increase the size of the array v initialized in:
class Vector {
private:
int capacity=100;
int v[100];
int size=0;
public:
void push_back(int item);
};
I want to double the size of the array in the implementation of the member function push_back if size = capacity. If I set v[2*capacity] in my implementation of the member function, I will receive a compiler error. How do I resolve this issue? Thank you all for your help.
Aucun commentaire:
Enregistrer un commentaire