Skip to content
Snippets Groups Projects
Commit 5cf3786e authored by Rudi Buss's avatar Rudi Buss
Browse files

Update Exercise 2 - Vehicle.txt

parent 96c9066a
No related branches found
No related tags found
No related merge requests found
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;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment