Professional Documents
Culture Documents
Operatori: Operator +
Operatori: Operator +
Operatori: Operator +
OPERATOR +=
RestaurantCuLivrari& operator+=(int x) {
this->costTransport += x;
return *this;
}
OPERATOR -=
RestaurantCuLivrari& operator-=(int x) {
this->costTransport -= x;
return *this;
}
OPERATOR +
RestaurantCuLivrari operator+(int x) {
RestaurantCuLivrari copie(*this);
this->costTransport += x;
return copie;
}
OPERATOR ++ PRE
RestaurantCuLivrari& operator++() {
this->costTransport += 100;
return *this;
}
OPERATOR ++ POST
RestaurantCuLivrari operator++(int) {
RestaurantCuLivrari copie(*this);
this->costTransport += 500;
return copie;
}
OPERATOR ==
OPERATOR <
int& operator[](int i) {
if (i >= 0 && i < this->nrMeniuri) {
return this->preturi[i];
}
else {
throw new exception("Index gresit.");
}
}
vn[nrMeniuri] = pretNou;
if (this->preturi) {
delete[]this->preturi;
}
preturi = vn;
nrMeniuri++;
}
Restaurant& operator--() {
int* vn;
if (nrMeniuri > 0) {
vn = new int[nrMeniuri - 1];
for (int i = 0; i < nrMeniuri - 1; i++) {
vn[i] = preturi[i];
}
if (this->preturi) {
delete[]this->preturi;
}
preturi = vn;
nrMeniuri--;
}
return *this;
}
OPERATOR - = CARE SCOATE DIN VECTOR DUPA INDEX
int getNrPreturiMaiMariCa(int x) {
int contorPreturiMaiMariCaX = 0;
for (int i = 0; i < this->nrMeniuri; i++) {
if (this->preturi[i] >= x) {
contorPreturiMaiMariCaX++;
}
}
return contorPreturiMaiMariCaX;
}
void sortare() {
for (int i = 0; i < nrMeniuri; i++) {
for (int j = i + 1; j < nrMeniuri; j++) {
if (preturi[i] > preturi[j]) {
int aux;
aux = preturi[i];
preturi[i] = preturi[j];
preturi[j] = aux;
} }
} }
OPERATOR +
Agentie operator + (Imobil im) {
Agentie copie = *this;
Imobil* vn = new Imobil[nrOferte + 1];
for (int i = 0; i < nrOferte; i++) {
vn[i] = oferte[i];
}
vn[nrOferte] = im;
if (copie.oferte) {
delete[] copie.oferte;
}
copie.oferte = vn;
copie.nrOferte++;
return copie; }
Tren & operator += (Vagon VagonNou) {
//nrvagoane 3
// V1 v2 v3
//vagoane (ad0) ---->[adv1][adv2][adv2]
//
Vagon ** v = new Vagon*[this->nrVagoane + 1]; // v (adv)------> [][][][]
for (int i = 0; i < this->nrVagoane; i++) { // v1 v2
v3 vagonNou
v[i] = new Vagon(* this->vagoane[i]); // v(adv)------ >
[advc1][advc2][advc3][advn ]
}
v[this->nrVagoane] = new Vagon ( VagonNou);
return *this;
}
//t3 -= 1;
Vagon ** v = nullptr;
if (this->nrVagoane > 0) {
int k = 0;
for (int i = 0; i < this->nrVagoane; i++) {
if (index != i) {
v[k++] = new Vagon(*this->vagoane[i]);
}
}
for (int i = 0; i < this->nrVagoane; i++) {
if (this->vagoane[i]) {
delete this->vagoane[i];
}
}
if (this->vagoane) {
delete[] this->vagoane;// vagoane(ad0)---- >
[0xcccc][0xcccc][0xcccc]
}
this->vagoane = v;
this->nrVagoane--;
}
return *this;
}
//OPERATORII += SI -= CARE PERMIT INCARCAREA/DESCARCAREA BATERIEI
BateriePowerBank& operator+=(int x) {
this->capacitate += x;
return *this;
BateriePowerBank& operator-=(int y) {
this->capacitate -= y;
return *this;
return true;
else {
return false;
//OPERATORUL FUNCTIE () CARE CALCULEAZA VALOAREA ASIGURARII INTR-O VALUTA PENTRU CARE
CURSUL DE SCHIMB ESTE TRANSMIS CA PARAMETRU
float operator()(float n)
return n * this->sumaAsigurata;
cout << "Suma asigurata este acum de: " << b3(4.10) << " lei."<<endl;
//OPERATORUL DE CONVERSIE LA DOUBLE A UNEI ASIGURARI
return this->sumaAsigurata;
//OPERATOR ()(int) CARE PRIMESTE NR. LOCUITORI DIN CASA SI RETURNEAZA TRUE DACA
FIECARE PERSOANA ARE POSIBILITATEA DE A AVEA PROPRIA CAMERA SI FALSE DACA SUNT MAI
PUTINE CAMERE DECAT PERSOANE.
return true;
return false;
//OPERATOR ! PENTRU A INDICA DACA O PETITIE NU ARE RASPUNS SI A DEPASIT TERMENUL LEGAT
DE 30 ZILE
return true;
else {
return false; } }
Apel: if (!p5) {
cout << "Petitia nu are raspuns si a depasit termenul de 30 zile." << endl;
else {
}
//OPERATOR ~ PENTRU A SCHIMBA STAREA UNEI PETITII ( DESCHISA->REZOLVATA )
void operator~() {
if (starePetitie== true) {
this->starePetitie = false;
else {
this->starePetitie = true;
Apel: ~p1;
//OPERATOR INDEX []
int& operator[](int i) {
return this->pretIntretinerePerApartament[i];
else {
double viz = 0;
viz = productii[i].getViz();
return viz;
Apel: cout << " Cea mai vizionata productie: " << endl;
float x = (double)s3;
if (strlen(numeFacultateNou) > 2) {
strcpy(this->numeFacultate, numeFacultateNou);
Apel: try {
d2.setNumeFacultate("A");
catch(Exceptie e){
}
//OPERATOR [] PENTRU LOCALIZAREA UNUI PRODUS DIN COS
Produs operator[](int i) {
if (i >= 0 && i<this->nrProduse) {
return this->produse[i];
}
else {
throw new exception("Index gresit");
}
}
cout << "PRODUSUL ASOCIAT INDEXULUI 2 ESTE: " <<c3[2] << endl;
Apel: cout << "S-A ADAUGAT UN PRODUS IN COSUL C3:" << endl;
c3 += p6;
cout << c3 << endl;