-
Notifications
You must be signed in to change notification settings - Fork 3
/
1045_seminar04.cpp
79 lines (62 loc) · 1.58 KB
/
1045_seminar04.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<iostream>
#include<string>
using namespace std;
class Makeup {
public:
const int id;
const int nrLuniValabilitate;
string denumire;
int nrProduse;
double* preturiProduse;
static double tva;
static int contor;
static int nrMakeUpUri;
Makeup():id(contor++),nrLuniValabilitate(12) {
denumire = "Mascara";
nrProduse = 3;
preturiProduse = new double[nrProduse];
for (int i = 0; i < nrProduse; i++) {
preturiProduse[i] = 10;
}
nrMakeUpUri++;
}
Makeup(int nrLuni, string denumire, int nrProduse, double* preturiProduse) :nrLuniValabilitate(nrLuni), id(contor++) {
this->denumire = denumire;
this->nrProduse = nrProduse;
this->preturiProduse = new double[nrProduse];
for (int i = 0; i < nrProduse; i++) {
this->preturiProduse[i] = preturiProduse[i];
}
nrMakeUpUri++;
}
~Makeup() {
delete []preturiProduse;
nrMakeUpUri--;
}
void afisare() {
cout <<id<<"."<< denumire << " are " << nrProduse << " cu preturile:";
for (int i = 0; i < nrProduse; i++) {
cout << preturiProduse[i] << ", ";
}
cout << endl;
}
};
double Makeup::tva = 0.19;
int Makeup::contor = 1;
int Makeup::nrMakeUpUri = 0;
void main(){
Makeup m1;
Makeup m2(6, "Ruj", 3, new double[3]{10,12,8});
m1.afisare();
m2.afisare();
cout << m1.nrMakeUpUri << endl;
{
Makeup m3;
cout <<"in corp:"<< m1.nrMakeUpUri << endl;
}
cout << "in afara corpului:" << m1.nrMakeUpUri << endl;
Makeup * pointerM1=&m1;
cout << Makeup::nrMakeUpUri << endl;
Makeup* pointerM2 = new Makeup();
delete pointerM2;
}