Template class in Managed C++
I have problem using template class in a managed C++ dll. I got error C2065:
'MyTempateCall' : undeclared identifier. I don't have problme use un-template
class.
Below is the simple example it has the same problem as my real project.
// The dll library
#pragma once
using namespace System;
namespace TestDll {
public ref class Class3
{
};
template<class T>
public ref class Class2
{
public:
Class2<T>(T theValue)
{
myValue = theValue;
}
private:
T myValue;
};
template ref class Class2<int>;
template ref class Class2<double>;
public ref class TestClassInSameNameSpace
{
void Test()
{
Class2<int> class2(60);
}
private:
Class3 class3;
};
}
// The Other application that uses the privious dll. Now I got this error:
error
// C2065: 'Class2' : undeclared identifier. It is fine with Class3.
#pragma once
using namespace System;
using namespace TestDll;
namespace CallTestDLL {
public ref class TestClass
{
void Test()
{
Class2<int> class2(60);
}
private:
Class3 class3;
};
}
I add the dll as the reference. I got same error message if I add the
library project as the reference.
What did I miss?
Thank you for any help.