+ 1

OPERATOR OVERLOADING PROBLEM IN C++

You are creating a program for a Bank to manage Accounts. The given code declares an Account class which has a balance and interest members. The bank asks you to add a new functionality to merge two accounts together, resulting in a new account with the sum of the balances and interests of the given accounts. Overload the + operator to allow adding two Account objects, adding the balances and interests. https://www.sololearn.com/learning/1051/1901/3743/1 PLEASE I COULD UNDERSTAND THE LOGIC AND ALSO PASSED THE QUIZ BY THIS CODE AS FOLLOWS: #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x,y,test; cin>>x>>y; cout<<(x+y)+((x+y)/10)<<"\n"; return 0; } BUT I couldn't solve with OOP....please help me I'm fraking out with this problem

11th May 2021, 7:45 PM
Shakil
1 ответ
+ 2
You have to continue learning, in the next lessons you'll learn operator overloading. In "More on classes" section there is a lesson about it
11th May 2021, 11:48 PM
Michal Doruch