Dynamic memory question

I have a class Myclass and the following:

struct Data {Myclass* a;};

vector<vector<Data> > data;

How do I go about to add a new object to the vector? The vector is 10x10. I was thinking about doing something like this:

new Myclass example;
data.at(2).at(2).a = example;

But I'm unsure of the syntax. Does that work or does it need &example or *(data.at(2).at(2).a)?
The syntax of accessing of an element of the vector is correct. It is incorrect the syntax of allocating new object of type MyClass. Should be

MyClass *example = new MyClass; // or MyClass()
Last edited on
So if I have a constructor in the class:

Myclass(int a, string b, int c);

I would do the operation like this?

data.at(2).at(2).a = Myclass(1, abc, 2);
data.at(2).at(2).a = new Myclass(1, abc, 2);
Oh right, forgot about the new. Thanks.
Topic archived. No new replies allowed.