1. This assignment asks to add some code from to a previous assignment I had. I have been confused about this overload operators alot and im confused on how to do it in my code any help with this will be good

A) overload the >> operator to allow for reading a new name and new balance from the keyboard and use the data to update the object's data members

B) Overload the << operator to dsiplay the Name, Balance, and Interest Rate of an object on the screen with proper labels.

C) Overload the += operator to allow an increase to a saver's Balance. (Saver1 += 1000;) use a void member function

D) Overload the -= operator to allow a decrease to a saver's Balance. (Saver1 -= 1000;) Use a void member function.

E) create a 4th object and use it to test all the member functions and overloaded operator functions.

here are the links to the three files for the pervious project:




here is the assignment as well from the pervious probject:


Re: C++ programming assignment for class that I am confused on 80 80

Use a friend method to overload those operators, for example

#include <iostream>
#include <fstream>
using namespace std;

class SavingsAccount
    friend ofstream& operator<<(ofstream& out, SavingsAccount& obj);
    string firstName;
    string lastName;
    float savingBalance;
    float annualInterestRate;
    int objectnumber;


ofstream& operator<<(ofstream& out, SavingsAccount& obj)
    out << obj.firstName << " " << obj.lastName
        << " " << obj.savingBalance << " " << obj.annualInterestRate << '\n';
    return out;


The other operators are similar to the above. For the >> operator use istream instead of ofstream and call it with cin

SavingsAccount obj;
cin >> obj;

For the << operator which I showed you how to code you just open an output stream.

SavingsAccount obj;
ofstream out("filename.txt");
out << obj;
Re: C++ programming assignment for class that I am confused on 80 80

How do you write the other overloaded operators += and -= using a void member funtion? Also confused on how to write the 4th object on step E

Re: C++ programming assignment for class that I am confused on 80 80

I'm not going to write your whole assignment for you. Doesn't your book cover operator overloading? There are lots of online tutorials, such as this one.

Don't worry about step E until you have the others finished.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.