Alright I am doing a project for different class and I think I have everything good but I cant get this line of code to get past without giving the error code about overloading a function
TestMenu.cpp
1 2 3 4 5 6 7 8
#include "MenuBuilder.h"
#include "MenuBuilder.cpp"
int main()
{
checkBal();
}
MenuBuilder.cpp
1 2 3 4 5 6
#include "Menubuilder.h"
void checkBal()
{
std::cout<<"Current balance is: $"<<balance<<std::endl;
}
you need to give the namespace a name then you need to do in the main nameofyournamespace::checkBal();
and in your .cpp file void nameofyournamespace::checkbal()
Most likely, in one or more of the functions you didn't post you wrote something like double balance; // more than once
The complete error message should tell you which file and which line the error is in. From there just call it balance and the first error should go away.
Actually, its because "balance" is being defined in multiple files, due to the header file being included in two different .cpp files. What you may want to do instead is something like this:
1 2 3 4
// extern tells the compiler that it can look in another file
externdouble balance;
externdouble Amount;
externdouble Ebalance;
And then simply make sure you remember to initialize balance somewhere in another file.