-
Private Class Functions
Hello Everyone!
I was wondering if someone could tell me how or refer me to a good place to find out how to call a private class function in a class's public member function.
This is how I did it:
Code:
void ATM::deposit(string ptrans, string pacct, int pmoney)
{
cout <<"It is working" << endl;
if(pacct == "Checking Account")
checkBal = checkBal + pmoney;
else if(pacct == "Savings Account")
saveBal = saveBal + pmoney;
void printRe(string ptrans, string pacct, int pmoney);
}//end deposit function
However when it gets to the printRe function call, it does not work.
Any ideas? I tried doing different kinds of function calls like the one you may use when calling a class function from a client program.
-
Does that even compile?
You call a private function like any other function. Say ATM::printRe is the private function, and ATM::deposit is the public function, then just:
Code:
void ATM::deposit(string ptrans, string pacct, int money)
{
// ...
printRe(ptrans, pacct, pmoney);
}
-
I see, but when I try it that way I received an error that said:
atm.cpp: In member function 'void ATM::deposit(std::string, std::string, int)':
atm.cpp:47: error: expected primary-expression before 'ptrans'
atm.cpp:47: error: expected primary-expression before 'pacct'
atm.cpp:47: error: expected primary-expression before 'int'
-
Post the code you're using.
-
OOOOHHHHH OOoops!!!!! Ok I see I see ^_^.
Thanks you soooooo much!!!
I was making stupid little mistakes.
THanks ^_-