Just wondering if I can have a vector as a class? I have an array as a class, and I have the functions within to add/change/delete an item, and even resize the array if need be. However, I had a go with doing the same with a vector but I got an error.
I was just wondering if this is possible or am I asking too much of vector? If it is possible, I'll post the bit of code I did which flagged up an error.
Thanks for the reply, but I was thinking something more along the lines of:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class NewVector {
public:
void AddValue(int p_item) {
m_vector.push_back(p_item); //Here's where I get the error, something about m_vector not being class/struct/union
}
private:
int m_vector;
};
int main() {
NewVector v1;
v1.AddItem('1');
return 0;
}
Also, your "array" sounds an awful lot like a vector -- a dynamically resized data structure of adjacent elements of the same type. Anything that matches that description is a vector.