Consultatie-Boja-25 03 2020
Consultatie-Boja-25 03 2020
Consultatie-Boja-25 03 2020
#include <iostream>
#include <string>
using namespace std;
class Email {
public:
Email(int id, const char* subject, string from,
TipEmail tip, int zi, int luna, int an):idEmail(id) {
strcpy(this->subject, subject);
this->from = from;
this->tip = tip;
this->zi = zi;
this->luna = luna;
this->an = an;
this->to = NULL;
this->continut = NULL;
this->nrAdreseDestinatie = 0;
}
void oFunctie() {
int an = this->an;
}
int getId() {
return this->idEmail;
}
~Email() {
if (this->continut != NULL)
delete[] this->continut;
delete[] this->to;
}
strcpy(rezultat.subject, this->subject);
rezultat.nrAdreseDestinatie =
this->nrAdreseDestinatie + 1;
rezultat.to = destinatari;
return rezultat;
}
//operator =
void operator=(const Email& email) {
//este constant
//this->idEmail = email.idEmail;
strcpy(this->subject, email.subject);
this->from = email.from;
this->zi = email.zi;
this->luna = email.luna;
this->an = email.an;
delete[] this->continut;
if (email.continut != NULL) {
this->continut = new char[strlen(email.continut) + 1];
strcpy(this->continut, email.continut);
}
else
this->continut = NULL;
delete[] this->to;
if (email.nrAdreseDestinatie != 0) {
this->to = new string[email.nrAdreseDestinatie];
for (int i = 0; i < email.nrAdreseDestinatie; i++)
this->to[i] = email.to[i];
this->nrAdreseDestinatie = email.nrAdreseDestinatie;
}
else
{
this->nrAdreseDestinatie = 0;
this->to = NULL;
}
this->tip = email.tip;
}
//constructor de copiere
Email(const Email& email):idEmail(email.idEmail) {
strcpy(this->subject, email.subject);
this->from = email.from;
this->zi = email.zi;
this->luna = email.luna;
this->an = email.an;
if (email.continut != NULL) {
this->continut = new char[strlen(email.continut) + 1];
strcpy(this->continut, email.continut);
}
else
this->continut = NULL;
if (email.nrAdreseDestinatie != 0) {
this->to = new string[email.nrAdreseDestinatie];
for (int i = 0; i < email.nrAdreseDestinatie; i++)
this->to[i] = email.to[i];
this->nrAdreseDestinatie = email.nrAdreseDestinatie;
}
else
{
this->nrAdreseDestinatie = 0;
this->to = NULL;
}
this->tip = email.tip;
}
};
if (email.continut == NULL)
consola << endl << "Fara continut";
else
consola << endl << email.continut;
if (email.nrAdreseDestinatie == 0) {
consola << endl << "To: -";
}
else {
consola << endl << "To: ";
for (int i = 0; i < email.nrAdreseDestinatie; i++)
consola << email.to[i] << ";";
}
}
char buffer[10000];
in >> buffer;
if (email.continut != NULL)
delete[] email.continut;
if (email.to != NULL)
delete[] email.to;
email.to = new string[email.nrAdreseDestinatie];
switch (tipCitit) {
case 1:
email.tip = TipEmail::IMPORTANT;
break;
case 2:
email.tip = TipEmail::NORMAL;
break;
case 3:
email.tip = TipEmail::EVENIMENT;
break;
default:
email.tip = TipEmail::NORMAL;
}
int main() {
Email email(1, "Tutoring C++", "[email protected]",
TipEmail::IMPORTANT, 25, 3, 2020);
//delete pEmail;
}