I have a problem with codeblocks ver 10.05. I made a c++ project, and I wrote a program like this:
main.cpp
#include <iostream>
#include "vectorddd.hpp"
using namespace std;
int main()
{
vector3D<int> tesztinttomb;
tesztinttomb.saveout("igen.dat");
return 0;
}
header file (vectorddd.hpp):
#ifndef VECTORDDD_HPP_INCLUDED
#define VECTORDDD_HPP_INCLUDED
#include <iostream>
template <class T>
class vector3D {
T *x;
T *y;
T *z;
int meret;
public:
void saveout(char* FileName);
vector3D(int Meret=0) : x(new T[meret]), y(new T[Meret]), z(new T[Meret]), meret(Meret) {}
~vector3D() { delete [] x; delete [] y; delete [] z; }
};
#endif // VECTORDDD_HPP_INCLUDED
implementation file (vectorddd.cpp):
#include "vectorddd.hpp"
template <class T>
void vector3D<T>::saveout(char* FileName) {
int i=0;// I know this is stupid... but the emphasis is on the linking problem
}
And it just doesn't link together. I know I have to check .cpp files link and compile settings at properties->build options. And I don't find any problem, but is just write always the same:
In function `main':
undefined reference to `vector3D<int>::saveout(char*)'
||=== Build finished: 1 errors, 0 warnings ===|
And if I put the .cpp files implementations into my .hpp file it works correctly. But this is not how codeblocks should work.