0
     template<class T>
class coulomn {
    public:
        coulomn();
        ~coulomn();
        int addcoulomn();
        int addvalue( int x, int y, T t);
        T printvalue( int x, int y);
        int resize( int x, int y);
    private:
        vector<vector<T>> matrix;
        int _sizeX, _sizeY;

};

        #include "coulomn.h"

template<class T>
coulomn<T>::coulomn() {
    _sizeX=0;
    _sizeY=0;
}
template<class T>
coulomn<T>::~coulomn() {

}
template<class T>
int coulomn<T>::addcoulomn(){
    matrix.emplace_back(NULL);
    return 0;
}      

i was trying to make a matrix with vector vector with an userdefined type , but my template class doesnt work. if i test it with for example int it works, but i can t implement the template

Hack Er
  • 11
  • 2
  • 1
    please include a [mcve] and the error – 463035818_is_not_an_ai Jun 05 '20 at 11:21
  • Did you put function definitions in cpp file? – Yksisarvinen Jun 05 '20 at 11:26
  • You are defining your class template in a header file, `coulomn.h`, but you don't provide definitions of the constructor, destructor or other member functions of the class template in the header file. Instead, you have placed these in separate source file; these are not definitions in the common sense, however, but rather _blueprints_ that can be used to _instantiate_ definitions. This means that a user of the `coulomn` class template will not have any definitions(/definition blueprints) available when it tries to _instantiate_ the class template for a specific type template parameter `T`. – dfrib Jun 05 '20 at 11:30
  • You most likely want to include the member function (blueprint) definitions in the header file, or, _less likely_, explicitly instantiate, in the source file where you have placed the (blueprint) definitions, the `coulomn` class template for a known set of types in place of the type template parameter `T`. The latter is uncommon and would not allow a user of `coulomn.h` to make use of the class template for other types than those that you have explicitly instantiated. – dfrib Jun 05 '20 at 11:32
  • I think you need to explicitly instantiate your class, try adding below code at end of your cpp file: `template class coulomn ;` for example: `template class coulomn` – elpidaguy Jun 05 '20 at 11:38
  • 1
    @elpidaguy That would most likely be an anti-pattern (solving an X Y problem) in this context, given that `coulomn` is intended to be a re-usable type, allowing users of the class template to instantiate it based on their custom needs. – dfrib Jun 05 '20 at 11:41

0 Answers0