c++ - How to define a 2D array of structures in the private parts of a class? -
i want define 2d array of structures in class in c++, how should it, here example approach struct tt
class swtlvn{ private: int a,b; tt yum[a][b]; };
can done in way? aos used member functions of class/ultimatey defined object cant defined inside member function. having defined externally going hassle no can do.
edit:
struct tt{ int a,b,c; tt(){} tt(int aa,int bb,int cc){a = aa; b = bb; c = cc;} };
without knowing more, should use similar to:
class foo { public: foo(int _a, int _b) : a(_a), b(_b) { yum.resize(a); (size_t = 0; < a; i++) { yum[i].resize(b); } } typedef std::vector<std::vector<tt> > ttvector2d; ttvector2d yum; };
Comments
Post a Comment