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
Post a Comment