I have a class:
class C{
public:
//Omitted
private:
shared_ptr<X> anArray[2];
};
and X
looks like:
class X{
public:
X(); //default constructor used by the above array declaration?
private:
std::unordered_map<int, double> a;
};
After I create my C
class, I access one of the two shared_ptr objects in the array, however, the memory doesn't seem to be initialised. By this I mean X::a
doesn't have any valid state.
I thought the array declaration in C
would create the shared_ptr<X>
s AND the X
objects?
Is there something I should be explicitly doing in the X default constructor?
Aucun commentaire:
Enregistrer un commentaire