#include #include using namespace std; class Carte{ char *titlu; char *autor; public: Carte(char *titlu=NULL, char *autor=NULL);// CONSTRUCTOR CU PARAMETRII Carte(const Carte &);// CONSTRUCTOR DE COPIERE virtual ~Carte();// DESTRUCTOR class Carte& operator=(const Carte&);// OPERATOR SUPRAINCARCARE EGAL friend istream & operator >> (istream &, Carte &);//FCT PRIETENA SUPRAINCARCARE OPERATOR CITIRE friend ostream & operator << (ostream &, Carte &);//FCT PRIETENA SUPRAINCARCARE OPERATOR SCRIERE char* getTitlu() const{// FUNCTIE PT A PRIMI TITLU CARE ESTE PRIVAT return titlu; }; }; istream & operator >> (istream &, Carte &x){ x.titlu = new char[200]; x.autor = new char[200]; cin.getline(x.titlu,200); cin.getline(x.autor,200); } ostream & operator << (ostream &st, Carte &x){ st << x.titlu << x.autor; return st; } Carte& Carte ::operator=(const Carte&x){ if (&x == this) return *this; this->titlu = x.titlu; this->autor = x.autor; return * this; } Carte::Carte(char *titlu, char *autor){ if(titlu!=NULL){ this->titlu = new char[strlen(titlu)+1]; strcpy(this->titlu, titlu); } if(autor!=NULL){ this->autor = new char[strlen(autor)+1]; strcpy(this->autor, autor); } } Carte::Carte(const Carte &c){ if(c.titlu!=NULL){ this->titlu = new char[strlen(c.titlu)+1]; strcpy(this->titlu, c.titlu); } if(c.autor!=NULL){ this->autor = new char[strlen(c.autor)+1]; strcpy(this->autor, c.autor); } } Carte::~Carte(){ if(titlu!=NULL) delete [] this->titlu; if(autor!=NULL) delete [] this->autor; } class Persoana{ char * nume; public: Persoana(char *nume=NULL); Persoana(const Persoana &); virtual ~Persoana(); class Persoana& operator=(const Persoana&); friend istream & operator >> (istream &, Persoana &); friend ostream & operator << (ostream &, Persoana &); char* scrieReview(const Carte &c){ char* x =new char[200]; sprintf(x,"Reviewul pentru cartrea %s trebuie terminat in doua saptamani",c.getTitlu()); //SPRINTF FORMATARE IN C TREBUIE AFLAT DESPRE ASTA return x; }; }; istream & operator >> (istream &, Persoana &x){ x.nume = new char[200]; cin.getline(x.nume,200); } ostream & operator << (ostream &st, Persoana &x){ st << x.nume; return st; } Persoana& Persoana ::operator=(const Persoana&x){ if (&x == this) return *this; this->nume = x.nume; return * this; } Persoana::Persoana(char *nume){ if(nume!=NULL){ this->nume = new char[strlen(nume)+1]; strcpy(this->nume, nume); } } Persoana::Persoana(const Persoana &c){ if(c.nume!=NULL){ this->nume = new char[strlen(c.nume)+1]; strcpy(this->nume, c.nume); } } Persoana::~Persoana(){ if(nume!=NULL) delete [] this->nume; } int main(){ Carte c; cin >> c; Persoana p; cin >> p; cout << p.scrieReview(c); }