Я пытался написать некоторый код, используя шаблоны, я пытался в течение нескольких часов, но все еще не могу решить эту ошибку:
14 C:\Users\urielbertoche\Desktop\main.cpp request for member 'defineConstante' in 'planilhaTeste', which is of non-class type 'planilha<double> ()()'
мой главный на данный момент, как:
int main (){
planilha<double> planilhaTeste();
unsigned int contador=0;
double number=0;
for(contador=0; contador<5; contador++)
{
cout<<"Escreva a constante para a celula "<<contador<<endl;
cin>>number;
planilhaTeste.defineConstante(contador, number); // this is line 14 by the way
planilhaTeste->primeiro=planilhaTeste->primeiro->prox;
cout<<planilhaTeste.termoConstante;
}
return 0;
}
все включения сделаны, мой заголовок выглядит так:
template <class Type>
class planilha{
protected:
struct celula{
double termoConstante;
Type resultadoFinal;
lista termos;
int numCelula;
celula *prox;
celula():prox(NULL){};
celula(double novoTermo, int numCel, celula *proxElo=NULL):termoConstante(novoTermo),
resultadoFinal(novoTermo), numCelula(numCel), prox(proxElo), termos(){};
};
celula *primeiro;
public:
planilha();
planilha(const planilha<Type>& origem);
~planilha(void);
planilha<Type> operator=(const planilha<Type>& origem);
void defineConstante(int numCel, const Type& valor);
bool insere_termo(unsigned int numCel, unsigned int refCel, double fator);
void apagar(unsigned int num_cel);
};
и код функции:
template <class Type>
void planilha<Type>::defineConstante(int numCel, const Type& valor){
celula * finder = primeiro;
while(finder!=NULL){
if(this->numCelula==numCel){
this->termoConstante = valor;
return;
}
finder=finder->prox;
}
}
Я действительно не могу понять, почему происходит эта ошибка. Может кто-нибудь мне помочь? Спасибо.