You are on page 1of 2

OPERATOR +=

Restaurant& operator+=(int pretNou) { Oras& operator+=(Restaurant restaurantNou) {

int* vn = new int[nrMeniuri + 1]; Restaurant** vn = new Restaurant*[this->nrRestaurante + 1];


for (int i = 0; i < this->nrMeniuri + 1; i++) { for (int i = 0; i <this-> nrRestaurante; i++) {
vn[i] = preturi[i]; vn[i] = new Restaurant(*this->restaurante[i]);
} }
vn[this->nrMeniuri] = pretNou; vn[this->nrRestaurante] = new Restaurant(restaurantNou);
if (this->preturi) {
delete[]this->preturi; for (int i = 0; i < this->nrRestaurante; i++) {
} if (this->restaurante[i]) {
this->preturi = vn; delete this->restaurante[i];
this->nrMeniuri++; }
}
return *this; if (this->restaurante) {
} delete[]this->restaurante;

}
this->restaurante = vn;
this->nrRestaurante+=1;

return *this;
}
OPERATOR -=

Restaurant& operator-=(int index) { Oras& operator-=(int index) {


int* vn; Restaurant** vn = NULL;
int k = 0; if (this->nrRestaurante > 0) {
if (index >= 0 && index<this->nrMeniuri ) { vn = new Restaurant * [this->nrRestaurante - 1];
vn = new int[nrMeniuri - 1];
for (int i = 0; i < this->nrMeniuri - 1; i++) { int k = 0;
if (i!=index) { for (int i = 0; i < this->nrRestaurante; i++) {
vn[k++] = preturi[i]; if (index != i) {
} vn[k++] = new Restaurant(*this->restaurante[i]);
} }
if (this->preturi) { }
delete[]this->preturi; for (int i = 0; i < this->nrRestaurante; i++) {
} if (this->restaurante[i]) {
preturi = vn; delete restaurante[i];
nrMeniuri--; }
} }
return *this; if (this->restaurante) {
} delete[] this->restaurante;
}
this->restaurante = vn;
this->nrRestaurante--;
}
return *this;
}

You might also like