-1

I am novice in the template programming.

What is the problem in this simple function?

template<class T>
void myFunction()
{
    basic_string<T>::size_type i = 0;

}

I cannot compile it?!

Changing class to typename does not solve the problem?

user1436187
  • 3,252
  • 3
  • 26
  • 59
  • Please give us more context. What errors are you getting? How are you trying to instantiate that template? Is that template included in the same compilation unit as your attempt to instantiate it? – user3553031 Jul 06 '14 at 07:17

1 Answers1

1

Use 'typename' keyword

typename basic_string<T>::size_type i = 0;

Suggested Reading :Where and why do I have to put the “template” and “typename” keywords?

Community
  • 1
  • 1
P0W
  • 46,614
  • 9
  • 72
  • 119