-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
69 lines (49 loc) · 1.99 KB
/
main.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
#include <iostream>
class Unviersity {
int numberOfStudents;
int numberOfTeachers;
int numberOfBuildings;
public:
Unviersity(int numberOfStudents, int numberOfTeachers, int numberOfBuildings) {
this->numberOfStudents = numberOfStudents;
this->numberOfTeachers = numberOfTeachers;
this->numberOfBuildings = numberOfBuildings;
}
Unviersity& operator+(const Unviersity& other) {
this->numberOfStudents += other.numberOfStudents;
this->numberOfTeachers += other.numberOfTeachers;
this->numberOfBuildings += other.numberOfBuildings;
return *this;
}
bool operator==( const Unviersity& other) const{
return this->numberOfStudents == other.numberOfStudents &&
this->numberOfTeachers == other.numberOfTeachers &&
this->numberOfBuildings == other.numberOfBuildings;
}
void print() {
std::cout << "Number of students: " << numberOfStudents << std::endl;
std::cout << "Number of teachers: " << numberOfTeachers << std::endl;
std::cout << "Number of buildings: " << numberOfBuildings << std::endl;
}
bool isEqual(const Unviersity& other) const {
return this->numberOfStudents == other.numberOfStudents &&
this->numberOfTeachers == other.numberOfTeachers &&
this->numberOfBuildings == other.numberOfBuildings;
}
};
int main(){
Unviersity akfaUniversity(200, 20, 10);
// akfaUniversity.print();
Unviersity nationalUniversity(200, 20, 10);
std::cout<< "before calling operator +"<< std::endl;
// akfaUniversity + nationalUniversity;
// akfaUniversity.print();
// int a =10;
// int b = 30;
// int a = a+b;
// // is this unvisrties are same?
std::cout<< "Equal: "<< (akfaUniversity == nationalUniversity) << std::endl;
// it is just like this
std::cout<< "Equal: "<< ("aziz" == "laziz") << std::endl;
std::cout<< "Equal: "<< (akfaUniversity.isEqual(nationalUniversity)) << std::endl;
}