std::vector and constructor

Let's say I have some code like this:
1
2
3
4
5
6
7
8
9
10
class A{

public: 
A();

private:
vector<vector<int> > mat;
int a;

}


In the default constructor should I initialize mat? And how do I access the elements of vector<vector<int> >? Thanks.:)
Constructors of class members are called when an object of a class is created. So you need not explicitly to call a vector constructor if it does not have to be ibitialized with some values.
You can access elements of vector with different ways: by using indexes, iterators, vector member functions as for example at().

Topic archived. No new replies allowed.