Sabhareesh Ravichandran Sabhareesh Ravichandran - 7 days ago 6
C++ Question

Does default argument of template class, instantiate the template?

Does the following default argument for the template instantiates a template with type

EmptyClass
?

class EmptyClass{};

template <typename TYPE=EmptyClass>
class Sample
{
public:
static void test()
{
TYPE::Serialize();
}
};

Answer

No, in that code any instance of EmptyClass is created. Serialize is a static function. And EmptyClass's constructor is never called (in code showed)

Comments