Variable Templates C++ 14

Hi everyone!

I am trying to get started with templates and variable templates but, when I am just trying to copy what Stroustrup says in its book, Xcode returns me 2 errors ("Expected ')' and 'Incomplete struct'").

Could you please me give an example to how to declare a Variable template with a struct and its constructor, variable declarations, destructors, etc.? In the book it is a bit messy and I'd need something simple to keep in mind!

Thanks

template<typename T> struct S{T val;};
Last edited on
Your example is apparently a declaration of a class template with a non-template non-static data member with a typo: it should be
template<typename T> struct S{T val;};

Variable templates are a different concept, they are not classes, so they cannot have constructors/destructors or "its variables".
There's a summary at http://en.cppreference.com/w/cpp/language/variable_template
Thanks for help Cubbi!
Topic archived. No new replies allowed.