Hi all,
I have a problem with template methods, what I want to do is pass in a struct type as a template variable but I don't know the correct way to do it.
Here is the method:
template<typename T>
void SetSize(unsigned int size, string inClass, T &inStart, T &inLast, T &inEnd, T inType) {
// delete any previous data
delete [] inStart;
// allocate new particles
if (inClass == "Particle")
{
inLast = inStart = new inType[size];
}
// set end
inEnd = inStart+size;
}
As you can see I want the inType to be able to be any struct that I pass in as an argument.
but when I try:
SetSize(100000, "Particle", start, last, end, Particle);
Particle is a struct but it says:
"Illegal use as this as an expression"
Please help,
thanks in advance.