You forgot the function call operator ()
. Change your main
code to:
int main(){
BankAccount bankAccount1("testName", 200.0);
cout << bankAccount1.amountOfMoney() << endl;
}
Without the parentheses it tries to print the address of a member function, which it is not able to do unless the function is not a member of a class.