Sem 6
Sem 6
class Student
{
private:
const int nrMatricol;
string nume;
int nrNote;
int* note;
float soldCont;
public:
this->nume = s.nume;
this->soldCont = s.soldCont;
delete[] this->note;
if (s.note != NULL && s.nrNote != 0)
{
this->note = new int[s.nrNote];
this->nrNote = s.nrNote;
for (int i = 0; i < this->nrNote; i++)
this->note[i] = s.note[i];
}
else
{
this->note = NULL;
this->nrNote = 0;
}
return *this;
}
void afisare()
{
cout << "Studentul " << this->nume << ", nr matricol: " <<
this->nrMatricol<<", sold cont: "<<this->soldCont;
cout << " are " << this->nrNote << " note: ";
if (this->note != NULL)
for (int i = 0; i < this->nrNote; i++)
cout << this->note[i] << " ";
else
cout << "-";
cout << endl;
}
~Student()
{
cout << "\nAPEL DESTRUCTOR";
//if (this->note != NULL)
delete[] this->note;
}
};
int main()
{
int note[] = { 10,4,6 };
Student s("Gigel", 3, note, 102, 100.5);
s.afisare();
return 0;
}
/////sa citim in carte de la pagina 52
Supraincarcarea op sa se descurce si cu obiecte de tip student