I want to define a 2D array of structures in a class in C++, how should I do it, here is an example approach for a struct tt
class swtlvn{ private: int a,b; tt yum[a][b]; }; Can this be done in some way? This AoS will be used by all the member functions of the class/ultimatey defined object so it cant be defined inside a member function. Having it defined externally is going to be a hassle so no can do.
EDIT:
struct tt{ int a,b,c; tt(){} tt(int aa,int bb,int cc){a = aa; b = bb; c = cc;} };
aandbgoing to be know at compile time or run time? If run time I suggest you use astd::vector.tt. It may be able to be used invector, but has to have proper copy semantics first.std::arrayoverstd::vectorif efficiency is a concern. stackoverflow.com/questions/4424579/…