Your code looks incomplete. If possible, always post your code as written on your computer.
Usually, you'd want to place the implementation of your class template inside the header file, i.e.
classe.h
Code:
#include <iostream>
template<typename Type> // I recommend 'typename' over 'class'
class Classe1 // I recommend uppercase names for user defined classes
{
public:
void printsizeof {
std::cout << sizeof(Type) << std::endl;
}
};
// Or if you want to define it afterwards:
template<typename Type>
void Classe1<Type>::printsizeof()
{
std::cout << sizeof(Type) << std::endl;
}
With a header file like that, you then wouldn't have a
classe1.cpp file at all.
If you insist on defining your template inside a cpp file, you'll have to declare the instantiation within that file (translation unit):
Code:
#include <iostream>
#include "classe.h"
template<typename Type>
void Classe1<Type>::printsizeof()
{
std::cout << sizeof(Type) << std::endl;
}
template class Classe1<int>; // You'd have to do this for any type...
// ...you instantiate your class template with. e.g.
// template class Classe1<double>;
C++ is weird like that. I hope this helped.