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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -