ragazzi ho una semplice funzione template:
codice:template <class T> void __debugLog(T msg, int level) { if (level <= DEBUG_LEVEL ) cout << "[Debug:" << level << "] " << msg << endl; }
come posso scrivere il prototipo di questa funzione nel mio file header.h?
riportando un pezzo da: http://www.cplusplus.com/doc/tutorial/templates/
praticmante dice che la dichirazione e l'implemetnazione di una funzione template devono stare nello stesso posto..Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.
ma se metto il codice nel mio file header.h il mio prof mi uccide all'istante credo