0
I started in the language c++ a short time and I am doubtful in methods specializations, I have two header files, arrangement and student, I want to use 2 methods of arrangement in student, but when declaring the method with specialization the eclipse points out the error "Member not found"If anyone can help me by clarifying why I made the mistake, I’d appreciate it. Below are the Arrangement and Student codes respectively.
#define ARRANJO_H_
#include <iostream>
using namespace std;
namespace arranjo{
template <class T>
class Arranjo {
private:
int tamanho;
T * items;
public:
Arranjo(int tam) {
this -> tamanho = tam;
this -> items = new T[tamanho];
}
virtual ~Arranjo(){}
virtual T get(int idx) {
if (idx < 0 || idx >= tamanho) throw "Erro! Esse Indice não existe";
return items[idx];
}
virtual void set(int idx, const T & item) {
if (idx < 0 || idx >= tamanho) throw "Erro! Esse Indice não existe";
this -> items[idx] = item;
}
virtual void exibir();
};
template<class T>
void Arranjo<T>::exibir() {
// exibir cada item numa linha da forma "<idx>: <item>"
for(int i = 0; i < tamanho; i++) {
cout << i << ": " << items[i] << "\n";
}
}
}
#endif /* ARRANJO_H_ */
#define ALUNO_H_
#include "arranjo.h"
using namespace arranjo;
class Aluno {
private:
string nome;
string mat;
public:
Aluno() {}
Aluno(const char * nome, const char * mat) : nome(nome), mat(mat) {}
friend class Arranjo<Aluno>;
};
template<>
void Arranjo<Aluno>::set(int idx, const Aluno & aluno) {
// Ao declarar este método especializado o Eclipse CDT exibe a mensagem de erro Member declaration not found
}
template<>
void Arranjo<Aluno>::exibir() {
// Ao declarar este método especializado o Eclipse CDT exibe a mensagem de erro Member declaration not found
}
#endif /* ALUNO_H_ */
Matheus this is the OS website in English, translate your question
– Ricardo Pontual