J
Jeff Newman
Hi all, I am trying to figure out what is causing the compile error in
the following example. I have two functions which are identical
(except one is templated), both trying to call a template function in
another class. The template function (func2) won't compile. I'm
hoping that I'm just missing something simple, but I can figure out
what it is.
struct A
{
template<typename T>
void DoIt(T t)
{
t++;
}
};
struct B
{
void other()
{
func2<int>();
}
void func1()
{
A a;
int x = 0;
a.DoIt<int>(x);
}
template<typename Y>
void func2()
{
A a;
Y x = 0;
a.DoIt<Y>(x); // FIXME: Compile error is here
}
};
The compile error is :
Test.cpp: In member function `void B::func2()':
Test.cpp:29: error: parse error before `;' token
where line 29 is the marked line.
Any help is greatly appreciated.
the following example. I have two functions which are identical
(except one is templated), both trying to call a template function in
another class. The template function (func2) won't compile. I'm
hoping that I'm just missing something simple, but I can figure out
what it is.
struct A
{
template<typename T>
void DoIt(T t)
{
t++;
}
};
struct B
{
void other()
{
func2<int>();
}
void func1()
{
A a;
int x = 0;
a.DoIt<int>(x);
}
template<typename Y>
void func2()
{
A a;
Y x = 0;
a.DoIt<Y>(x); // FIXME: Compile error is here
}
};
The compile error is :
Test.cpp: In member function `void B::func2()':
Test.cpp:29: error: parse error before `;' token
where line 29 is the marked line.
Any help is greatly appreciated.