when compiling this simple code,i get this error:
[Error] no matching function for call to 'Studente::Registra()'
#include<iostream>
using namespace std;
class Anagrafica{
public:
int codice;
string cognome;
string nome;
void Mostra();
void Registra();
private:
bool registrato;
};
void Anagrafica::Registra()
{
registrato=true;
}
void Anagrafica::Mostra()
{
if(registrato){
cout<<nome<<endl
<<cognome<<endl
<<codice;
}
else
cout<<"\nNon registrato \n";
}
class Studente : public Anagrafica{
int anno;
char sezione;
bool promosso;
public:
void Registra(int, char);
void Promuovi();
void Controlla();
void Mostra();
Studente(){
promosso = false;
anno = 0;
}
};
void Studente::Mostra()
{
Anagrafica::Mostra();
if (anno) cout<<anno<<" "<<sezione<<endl;
}
void Studente::Registra(int a, char s)
{
anno = a;
sezione = s;
}
void Studente::Promuovi()
{
promosso = true;
}
void Studente::Controlla()
{
if(promosso) cout<<"\nStudente promosso\n";
else cout<<"\nStudente NON promosso\n";
}
int main(){
Studente stud1;
char risp,sez;
int anno;
cout<<"\nNome: ";
cin>>stud1.nome;
cout<<"\nCognome: ";
cin>>stud1.cognome;
cout<<"Codice: ";
cin>>stud1.codice;
cout<<"Anno Scolastico: ";
cin>>anno;
cout<<"Sezione: ";
cin>>sez;
stud1.Registra(anno,sez);
stud1.Registra();
cout<<"Promosso? (s/n) ";
cin>>risp;
if (risp=='s') stud1.Promuovi();
stud1.Mostra();
stud1.Controlla();
return 0;
}
i dont understand the problem, shouldn't the function overloading should take care of the call for 'Registra()'?