Consider the following class with instance variable a initialized to a vector of length 3:
class A {
public:
vector<int> a = vector<int>(3);
};
This works fine, but notice that the type vector is repeated twice. Is there any way to write that type just once? (In real life, I'm dealing with way more verbose type names.)
I thought this ought to work:
class A {
public:
vector<int> a(3);
};
but nope, it doesn't for C++11 anyway, perhaps because that looks suspiciously like 'a' is declared as a member function.
Aucun commentaire:
Enregistrer un commentaire