What other way are you looking for? In any case, you need to define a default constructor if you intend to use it.
For example, you can define your class as follows
class T
{
public:
T() = default;
T(int h){item = h;}
int item = 0;
};
Or do you need to explicitly define the constructor
class T
{
public:
T() : item( 0 ) {}
T(int h){item = h;}
int item;
};
And another example
class T
{
public:
T() : T( 0 ) {}
T(int h){item = h;}
int item;
};
source
share