Untitled
unknown
plain_text
3 years ago
640 B
2
Indexable
#include<iostream> using namespace std; class Distance { private: int feet; int inch; public: Distance() { } Distance(int a, int b) { feet=a; inch=b; } Distance operator *=(Distance d); void display(); }; Distance Distance::operator *=(Distance d2) { Distance d3; int tempfeet1=tempfeet1+feet+(inch/12); int tempfeet2=tempfeet2+d2.feet+(d2.inch/12); int totalfeet=tempfeet1*tempfeet2; totalfeet } void Distance::display() { cout<<"In inch:"<<inch<<" "<<"In feet:"<<feet; } int main() { Distance d1(5,6),d2(4,7),d3; d3=(d1*=d2); d3.display(); }
Editor is loading...