struct Mystruct
{
int x;
int y;
Mystruct(int x, int y);
}
------------------------
class Myclass
{
Mystruct** p;
Myclass(int n);
}
------------------------
Myclass::Myclass(int n)
{
this->p = new Mystruct*[n];
for ( int i = 0; i < n; i++ )
this->p[i] = new Mystruct[n];
}
This will not work. I know the problem lies somewhere with default constructor not being available, but I do not know how to move forward from here.
this->p*why that '*' ?this->p[I] = new MyClass();std::vector<std::vector<Mystruct>> p (n, std::vector<Mystruct>(n));would be much safer and avoid manual memory management. Anyway, it's unclear to me what you want all theMystructto contain in terms of data.