So, I use std :: map as an associative array. The card is declared as such:
std::map<int, CustomClass*> CustomContainer;
Subsequently, I use the CustomContainer object as an associative array, for example,
CustomClass* pClass = CustomContainer[ID]
Josuttis states:
If you use the key as an index for which an element does not yet exist, a new element is automatically added to the map. The value of the new element is initialized by the default constructor of its type. Thus, to use this function, you cannot use a value type that does not have a default constructor
The map value is of type CustomClass *. Will the default be NULL, or is it undefined? (I think this is not the case, since the "pointer" is not a fundamental data type). I would have thought that he would also rely on the constructor and the behavior there .... thoughts ???
The only CustomClass constructor is as follows:
CustomClass::CustomClass(ClassA param1, ClassB param2, ClassC param3, ClassD param4)
:privateClassA(param1),
privateClassB(param2),
privateClassC(param3),
privateClassD(param4)
{
}
Thanks a lot!
source
share