c++ - What is this template syntax and unsigned type? -
i'm new c++ , have difficulty understanding code:
template <typename t = unsigned> - what
t = unsignedmeans? - does compiler enforce
unsignedon given type?
that's default template parameter; similar default function parameter. if don't put in argument, default unsigned [int]. imagine this:
template <typename t = unsigned> struct foo { t one; t two; }; if declare example foo<char>, resulting structure have 2 char members. default parameter lets me declare foo<>, , that structure have 2 unsigned int members, because unsigned int default.
Comments
Post a Comment