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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -