
calling template member function in template class
Hi all, hopefully there is a work around for this problem.
I'm trying to call a template member function in a template class and am not
having any luck.
I've tested the following code on:
http://www.*-*-*.com/
and it compiles fine - however MVC 6.0 doesn't seem capable of doing it.
class Object {};
class Test : Object {};
template <class T>
class SmartPtr{
public:
template <class U>
int foo (){
return 435;
}
Quote:
};
int main (){
SmartPtr<Test> testPtr;
testPtr.foo <Object>();
Quote:
}
------------------------------------------
Can anyone tell me if there is a work-around in C++ so that MVC 6.0 (service
patch 5) can actually do the above or something similar?
Obviously in this case, I don't actually need the class in the foo
function - but this is a dumbed down version of what I would like to get
working. I.E. I tried to reduce the problem I'm having down to the basics -
that is the requirement for a template function in a template class.
Thanks,
Novice
PS When I attempt to do the above in MVC it gives a compiler error of:
c:\tim\c++programs\timdynamic\mainentry.cpp(30) : error C2275: 'Object' :
illegal use of this type as an expression
c:\tim\c++programs\timdynamic\mainentry.cpp(14) : see declaration of
'Object'
c:\tim\c++programs\timdynamic\mainentry.cpp(30) : error C2059: syntax error
: ')'