So as the title reads, i want to create a template class and put methods/functions implementations into the relative source file. After some research on the internet i found some perplexing solution with something about making an extra file and including it in the header.
I know that it is possible to place all the implementations inside header file and it will work just fine. Also a side question to that is: Is it commonly acceptable as the best solution to place all the implementations inside header or not because in a comparison to ADT in C you kinda want to hide the implementation in the source file, is it the same case right here?
A little example: Lets say i want a 2-D plane of dots that are characters and i want to use the following code.
Point.h
#ifndef POINT_H_
#define POINT_H_
template <class T>
class Point {
T* x;
T* y;
public:
Point();
};
#endif
Point.cpp
#include "Point.h"
template <class T>
Point<T>::Point(){
x=new T;
y=new T;
}