c++ - Knowing the type of the template outside the class -


to make clear, want imitate behaviour of value_type member of std::vector.

for example:

template <class t> class foo{     //some declaration , definition value_type };  int main(){     foo<int> bar;     bar::value_type x=5; //x int } 

how can implement it?

try:

template <class t> class foo { public:     typedef t value_type; }; 

btw: bar::value_type invalid, should use as:

foo<int>::value_type x = 5; //x int 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -