0
What does int * v[3] would do? I think it will create a vector of pointers but it doesn't let me add values to those pointers
I'm using v[0]= 2; to add a value to them
5 Respuestas
+ 2
at() method only for vector. Not for array. You have to create vector of Name class type to use it.
+ 1
Well, for creating vector you have to write it like
vector<int> v[3];
What you are writing will create three pointers in array. Also when adding or change value in vector use at() method. It will throw an error if there is no index.
+ 1
int, string are structure not class. You have to define structure if you only want to store something in it. class are like structure with function and many other features. If you use it like you said, in your second post. You can add data to it like
Name *obj[4];
obj[0] = new John();
obj[1] = new David();
obj[3] = new Daniel();
Where John, David and Daniel are Name class type object.
0
In this case let's say I have a class called Name and I want to create an array with them so I used, Name * v[3], what am I creating in there? And how can I add values?
0
Oh I get it, and if I use it with int, as you said on the first answer, how should I use the at()? I tried it but I gave me a compilation error