Three questions about template function

I have read at cpp reference that in case of function that uses template <class T> I have to write the code at the header file, I cannot separate the header and implementation , isn't ?

Ok, my second question I suspect that my compiler (mingw) are doing something strange. I have one function defined using templates which does not recompile ? I have to clean and build again all my project (maybe it could be sufficient to delete the class has problems). Any idea ? It is as the compiler does not take into account my changes

template <class T>
std::string format(T number, std::string format){
// if I write some new code inside it is not recompiled ?????
}

My third... I have this error using a custom class. ( a very simple class)
there are no arguments to 'Acustomclass' that depend on a template parameter, so a declaration of 'AcustomClass' must be available
Any idea ?


Thanks
Last edited on
I have read at cpp reference that in case of function that uses template <class T> I have to write the code at the header file, I cannot separate the header and implementation , isn't?
Not necessarily. But it is routinely done that way.

I have one function defined using templates which does not recompile ? I have to clean and build again all my project
You will need to post the function and the errors that you get and where what lines of code the errors refer to.

My third...
You'll have to post the code of the definition and use. You're not at all clear on this point.
Answering to the second...
I have no errors, simply my changes to the function are not take into account.
By now, I have decided to create a 'clon' of the function becasue I cant spend more time with this theme, but believe me, I have to clean my project every time I did changes into template function.
Maybe the reason can be that this function is stored by the header file and something is related with the 'precompiled headers' ?
Thanks
I have no errors, simply my changes to the function are not take into account.
Thet's a build issue. What environment are you using?

Maybe the reason can be that this function is stored by the header file and something is related with the 'precompiled headers'?
Is the function in a header file? Is that header file explicitly part of the project?

It's impossible to give specific advice without knowing what you have.
Topic archived. No new replies allowed.