samedi 27 avril 2019

How to construct class that can replace typedef vector

I am learning classes in C++ and would like to construct my own class instead of using a 2D vector "typedef vector> C_type". I have some code written:

class T {
    public:
    int a;
    int b;
    T(int a, int b) : a(a), b(b){}

};

Now I have:

typedef vector<vector<T>> C_type;


I'd like to use a class instead and create a constructor and initialize it, something like:

class C_type {
vector<vector<T>> name;
C_type();}
C_type::C_type(){name = vector<vector<T>>(..........

I'd like to use the 2D vector as a class member. Thanks.

Aucun commentaire:

Enregistrer un commentaire