I've got header file with template class:
#ifndef BUBBLE_H
#define BUBBLE_H
#include "algorithm.h"
template <typename T>
class Bubble : public Algorithm <T> {
public:
Bubble(T* in, int inSize) : Algorithm<T>(in, inSize){}
void compute();
};
#endif // BUBBLE_H
if I put whole body of compute() class here everything works fine. But I would like to have it in cpp file. I wrote:
#include "bubbleSort.h" using namespace std;
template <typename T>
void BubbleSort<T>::compute(){ //(*)
for (int i = 1; i<this->dataSize; i++){
for (int j = this->dataSize-1; j>=i; j--){
if(this->data[j] < this->data[j-1]) swap(this->data[j-1], this->data[j]);
}
} }
But I received error in line (*):
error: expected initializer before '<' token void BubbleSort::compute(){ ^
How I should fix it?