First of all it's "int main()", not "void main()" void has never been a valid return type for main in C or C++.
Next, you need to deal with the compiler errors in the order they appear in the build output. Prior to the error you mentioned you should get the following error:
Code:
error C2955: 'Sqr' : use of class template requires template argument list
That is telling you that you need to use Sqr<int>::doIt. The compiler isn't goint to try and work out the parameter types for the member function when it doesn't even know what class instantiation you're talking about first.
Then after fixing that you'll get the following error:
Code:
error C2352: 'Sqr<T>::doIt' : illegal call of non-static member function
This means you either need an object of type Sqr<int> to call this on, or you need to declare the function as static. I assume the later is intended here.
Now magically the other error has vanished. If you don't start with the first error you can quite often be looking at an error that is simply a consequence of an earlier error, and not actually an error in itself at all.
This also then wont compile:
Code:
for (T* i=begin, int z = 0; i != end; i++, z++)
You can't declare two variables of different types in a for-loop. And this look like you're attempting to call an int as though it is a function!I suggest perhaps getting the code you're writing to work with concrete types first, and then convert it to template code.