diff --git a/Part 2/6. Operator overloading/Exercises/Exercise 2 - Vehicle.txt b/Part 2/6. Operator overloading/Exercises/Exercise 2 - Vehicle.txt index 40d552c57d774186a55342a3a8c6a6820db6f6ba..e5d76e0279d7d12306f46f2faa5df7d229922df0 100644 --- a/Part 2/6. Operator overloading/Exercises/Exercise 2 - Vehicle.txt +++ b/Part 2/6. Operator overloading/Exercises/Exercise 2 - Vehicle.txt @@ -1 +1,34 @@ -Overload the comparative operator so that it outputs whether a vehicle is the same or not. A vehicle is the same if its data members match. Additionally overload the greater than/ less than operator so that it outputs whether a vehicle is "older", "newer" or "the same age" (data member value yearOfConstruction). Use the following program: #include "iostream" #include "cstdlib" using namespace std; class Vehicle { private: string brand; string licencePlate; int hp; int yearOfConstruction; public: void displayData() { cout << "Brand: " << brand << endl; cout << "Licence plate: " << licencePlate << endl; cout << "Number of HP: " << hp << endl; cout << "Year of construction: " << yearOfConstruction << endl; } }; int main() { system("pause"); return 0; }; \ No newline at end of file +Overload the comparative operator so that it outputs whether a vehicle is the same or not. A vehicle is the same if its data members match. +Additionally overload the greater than/ less than operator so that it outputs whether a vehicle is "older", "newer" or "the same age" (data member value yearOfConstruction). + + +Use the following program: + + +#include <iostream> + +using namespace std; + +class Vehicle +{ +private: + string brand; + string licencePlate; + int hp; + int yearOfConstruction; + +public: + void displayData() + { + cout << "Brand: " << brand << endl; + cout << "Licence plate: " << licencePlate << endl; + cout << "Number of HP: " << hp << endl; + cout << "Year of construction: " << yearOfConstruction << endl; + } +}; + +int main() +{ + + return 0; +};