#include <iostream> #include <cstdint> using namespace std; class Distance { private: int32_t meters; public: Distance(int32_t m) : meters(m) {} // Define operator+ to add two Distance object Distance operator+(const Distance& other) const { return Distance(this->meters + other.meters); } int32_t getMeters() const { return meters; } }; int main() { int32_t a,b; cin >> a >> b; Distance d1(a); Distance d2(b); Distance total = d1 + d2; cout << total.getMeters() << endl; return 0; }
Test Cases
Test Results
Input
5 7
Expected Output
Total=12