How to initialize a template object inside a class C++?

Solution 1:

Either you can write

Node() : val() {}

or

Node() : val{} {}

Or in the class definition to write

T val {};