Semester : SEMESTER 6
Subject : Object Oriented Programming
Year : 2018
Term : MARCH
Scheme : 2015 Full Time
Course Code : EC 312
Page:5
// method to display distance
void displayDistance() {
cout << وع" " << feet << 7: << inches <
// overloaded minus (-) operator
Distance operator- () {
feet = -feet;
inches = -inches;
return Distance(feet, inches);
7
| int main() {
Distance D1(11, 10), D2(-5, 11);
-D1; പു negation
D1.displayDistance(); // display D1
-D2; // apply negation
D2.displayDistance(); // display 02
return 9;
When the above code is compiled and executed, it produces the following result —
5: -11 I:-10
Pe ~ 2:13)