c++ - What is this template syntax and unsigned type? -


i'm new c++ , have difficulty understanding code:

template <typename t = unsigned> 
  1. what t = unsigned means?
  2. does compiler enforce unsigned on 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

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -