I was given some code that looked like this (I added the default constructor and private declarations) and asked to make a program with it (I was also given a main function that did all the manipulation of money and output, but that didn't seem relevant to include). Seems easy, except the functions that are declared of type PiggyBank (PiggyBank& PiggyBank::addPennies(int p)). What do I return for these???
#ifndef PIGGYBANK_H
#define PIGGYBANK_H
class PiggyBank
{
public:
PiggyBank();
PiggyBank(int pennies, int nickels, int dimes, int quarters);
// Return the number of coins in the bank
int getPenniesCount() const;
int getNickelsCount() const;
int getDimesCount() const;
int getQuartersCount() const;
// Add coins to the bank
PiggyBank& addPennies(int p);
PiggyBank& addNickels(int n);
PiggyBank& addDimes(int d);
PiggyBank& addQuarters(int q);
// Withdraw coins from the bank, return number withdrawn
int withdrawPennies(int p);
int withdrawNickels(int n);
int withdrawDimes(int d);
int withdrawQuarters(int q);
void displayBalance() const;
void breakTheBank(); // Display the balance then cash out (all counts zeroed).
private:
int pennies;
int nickels;
int dimes;
int quarters;
};
#endif