I have a utils.h and a utils.cpp that contain utility functions, all surrounded by a common namespace. When I directly include the utils.h into a project, I can access all these functions.
utils.h:
namespace Utils
{
template <class T>
T interpolationLinear ( array<T,1>^ i_aData,
double i_dRatio)
{
array<T,1>^ aPart = gcnew array<T,1>(2);
aPart[0] = i_aData[0] * (1 - i_dRatio);
aPart[1] = i_aData[1] * (i_dRatio);
return aPart[0] + aPart[1];
}
...
double parseToDouble (System::String ^sValue); // defined in cpp
}
Now I am creating several managed DLLs and the utility functions should become one of them. The problem: I can not access the functions in the DLL/assembly any more. Seems like only classes can build the DLL interface.
I have then changed the namespace to a public ref class and made the functions static, so I got the access to some of the functions back:
utils.h:
public ref class Utils
{
template <class T>
static T interpolationLinear (array<T,1>^ i_aData,
double i_dRatio) // NO ACCESS
// like above
...
static double parseToDouble (System::String ^sValue); // CAN BE ACCESSED NOW
};
But why can't I call the template function? What is going wrong here?