У меня есть файл заголовка Algo.h
. Она имеет следующее содержание:Ошибка: некоторый класс не является шаблоном
#include <iostream>
#include <fstream>
#include <math.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
//some static functions
// ...
template <class Type> class Algo{
int
public:
Algo(int size, int num, int plth, int theN, float** theAg, int theLN,
float* theIn, float theeEps = 1E-3, float theEpsilonLR = 1E-3,
int theCycle = 30, bool DebInf = false, int theT = -1, int** theX = 0,
const char* theFileName = 0, const char* theFileNameChar = 0);
~Algo();
//some methods
//...
};
//Constructor
template <class Type> Algo<Type>::Algo(int size, int num, int plth, int theN, float** theAg, int theLN,
float* theIn, float theeEps = 1E-3, float theEpsilonLR = 1E-3,
int theCycle = 30, bool DebInf = false, int theT = -1, int** theX = 0,
const char* theFileName = 0, const char* theFileNameChar = 0){
//...
}
// ...
Тогда я хотел бы Usel его в main.cpp
:
#include "Algo.h"
#include <float.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
Algo<int>* construct1(const int & rt, float** & rm); //error: Algo is not a template
Algo<int>* construct2(const int & rte, float** & rm, Algo<int>* & the1, const bool & rob1); //error: Algo is not a template
//...
int main(){
//...
return 0;
}
Кажется, что все должно работать нормально, но я всегда получаю эту ошибку:
Algo is not a template.
У вас есть идеи, как это исправить?
На первом, вы используете слишком. многие параметры. Это не очень хорошая практика, потому что программа не может быть легко прочитана. После этого вы должны использовать 'Algo * construct1 = new Algo (...)' или 'Algo construct1 (...)'. –
Jepessen
Действительно ли нужно префикс имен переменных с 'the' ..? – OJFord
Параметр шаблона не используется. Возможно, это оптимизировано, как ненужное, а затем «Алго» действительно не является шаблоном. – OJFord