Hi, I'm making three bank account classes but this is just the basic one. I am having trouble with the withdraw function, mainly due to me not understanding how to correctly use the friend method when it come to overloading operators. Any help explaining how to correctly use it in this situation would be brilliant.
The withdraw function gives me these errors
1>myBasic.cpp(34): error C2556: 'void myBasic::withdraw(double)' : overloaded function differs only by return type from 'bool myBasic::withdraw(double)'
1> c:\users\desktop\bank\myBasic.h(9) : see declaration of 'myBasic::withdraw'
1>myBasic.cpp(34): error C2371: 'myBasic::withdraw' : redefinition; different basic types
1> c:\users\desktop\bank\myBasic.h(9) : see declaration of 'myBasic::withdraw'
1>myBasic.cpp(39): error C2143: syntax error : missing ';' before 'return'
#include <iostream>
#include <iomanip>
#include <ctime>
#include "myBasic.h"
using namespace std;
myBasic::myBasic(double amount)
{
if (amount > 0)
{
balance = amount;
}
else
{
cerr <<"You cannot open a new account without any money"<<endl<<endl;
}
}
void myBasic::deposit(double amount)
{
balance += amount;
}
void myBasic::withdraw(double amount)
{
if (amount < getBalance())
{
balance =balance - amount
return true;
}
else
{
balance = balance;
return false;
}
}
double myBasic::getBalance()
{
return balance;
}
#pragma once
class myBasic
{
#ostream& operator << (ostream& out, ???
public:
myBasic (double ammount= 0.0);
void deposit(double amount);
bool withdraw(double amount);
double getBalance();
private:
double balance;
};