Escolar Documentos
Profissional Documentos
Cultura Documentos
h";
#include<iostream>
#include<string>
class Apartament {
private:
string adresa;
char proprietar[50];
const unsigned int an_constructie;
double pret;
unsigned int numar_camere;
float* suprafete_camere;
public:
Apartament();
Apartament(string v_adresa, char v_proprietar[50], unsigned int
v_an_constructie, double v_pret, unsigned int v_numar_camere, float*
v_suprafete_camere);
Apartament(const Apartament& copie);
~Apartament();
Apartament& operator=(const Apartament& apartament);
friend ostream& operator<<(ostream& out, Apartament a);
friend istream& operator>>(istream& in, Apartament& a);
//operator functie
float operator()();
//operator index
float operator[](int index);
//operator negatie
bool operator!();
//operator ==
bool operator==(Apartament apartament);
// cast explicit
explicit operator double();
};
int main() {
return 0;
}
Apartament::Apartament() :an_constructie(0) {
this->adresa = "Anonim";
this->numar_camere = 0;
strcpy(this->proprietar, "Anonim");
this->pret = 0;
this->suprafete_camere = NULL;
}
if (v_proprietar != NULL) {
strcpy(this->proprietar, v_proprietar);
}
else {
strcpy(this->proprietar, "Anonim");
}
this->pret = v_pret;
this->numar_camere = v_numar_camere;
if (v_suprafete_camere != NULL) {
this->suprafete_camere = new float[this->numar_camere];
for (int i = 0; i < this->numar_camere; i++) {
this->suprafete_camere[i] = v_suprafete_camere[i];
}
}
}
this->adresa = copie.adresa;
strcpy(this->proprietar, copie.proprietar);
this->pret = copie.pret;
this->numar_camere = copie.numar_camere;
if (copie.suprafete_camere != NULL) {
this->suprafete_camere = new float[this->numar_camere];
for (int i = 0; i < this->numar_camere; i++) {
this->suprafete_camere[i] = copie.suprafete_camere[i];
}
}
}
this->adresa = apartament.adresa;
strcpy(this->proprietar, apartament.proprietar);
this->pret = apartament.pret;
this->numar_camere = apartament.numar_camere;
if (this->suprafete_camere != NULL) {
delete[] this->suprafete_camere;
}
if (apartament.suprafete_camere != NULL) {
this->suprafete_camere = new float[this->numar_camere];
for (int i = 0; i < this->numar_camere; i++) {
this->suprafete_camere[i] = apartament.suprafete_camere[i];
}
}
return *this;
}
Apartament::~Apartament() {
if (this->suprafete_camere != NULL && this->numar_camere > 0) {
delete[] this->suprafete_camere;
}
}
return out;
}
if (a.numar_camere > 0) {
a.suprafete_camere = new float[a.numar_camere];
for (int i = 0; i < a.numar_camere; i++) {
cout << "Suprafata camerei " << i + 1 << " este: ";
in >> a.suprafete_camere[i];
}
}
else {
a.suprafete_camere = NULL;
}
return in;
}