this->nrLuni += 1;
delete[] this->punctePeLuna;
this->punctePeLuna = new float[nrLuni];
for(int i=0;i<nrLuni;i++)
punctePeLuna[i] = v[i];
}
return *this;
}
};
ostream& operator<<(ostream& out,CardFidelitate c)
{
out<<"Puncte disponibile: "<<c.puncteDisponibile<<endl;
out<<"Posesor: "<<c.posesor<<endl;
out<<"Numar de luni: "<<c.nrLuni<<endl;
out<<"Puncte pe luna: "<<endl;
for(int i=0;i<c.nrLuni;i++)
cout<<"Luna "<<i+1<<": "<<c.punctePeLuna[i]<<endl;
out<<"Cod card: "<<c.codCard;
return out;
}
istream& operator>>(istream& in,CardFidelitate& c)
{
cout<<"Puncte disponibile: ";
in>>c.puncteDisponibile;
char aux[50];
cout<<"Nume posesor: ";
in>>aux;
if(c.posesor != NULL)
delete[] c.posesor;
c.posesor = new char[strlen(aux)+1];
strcpy(c.posesor,aux);
cout<<"Numar luni: ";
in>>c.nrLuni;
if(c.punctePeLuna != NULL)
delete[] c.punctePeLuna;
c.punctePeLuna = new float[c.nrLuni];
cout<<"Puncte pe luna"<<endl;
for(int i=0;i<c.nrLuni;i++)
{
cout<<"Puncte pe luna "<<i+1<<": ";
in>>c.punctePeLuna[i];
}
return in;
}
void main()
{
float v[] = {10,20,30,40,50};
CardFidelitate c(100,"Andrew",5,v,10); //constr cu parametrii
CardFidelitate c1 = c; //constructor de copiere
CardFidelitate c2; //constructor implicit
c2 = c1; //operator egal
/*CardFidelitate c3;
cin>>c3;
cout<<c3;*/
cout<<c2.TotalPuncteVechime()<<endl;
c2 += 10; //operator +=
cout<<c2;
//nu am testat toate posibilitatile, daca apare orice eroare postati va rog
}