c++ - template class method in source file -


i've got header file 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 put whole body of compute() class here works fine. have in cpp file. wrote:

#include "bubblesort.h" using namespace std;  template <typename t> void bubblesort<t>::compute(){   //(*)     (int = 1; i<this->datasize; i++){         (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 received error in line (*):

error: expected initializer before '<' token void bubblesort::compute(){ ^

how should fix it?

it's because you're mixing bubble , bubblesort, headers bubble.h , bubblesort.h.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -