Question about classes
Im just messing around with classes and im creating a checking account type deal.
I have the program prompt the user for their:
than it displays their information plus the balance
i have everything inside an inline function
and a while loop that keeps prompting the user if they have another transaction.
My problem is whenever i call the function from main the balance is automatically set to 0.
I dont have the program on me so i dont know if that would help more but basically inside the function i have balance intialized to 0 and after the deposit is read in i have balance = balance + deposit, but im assuming since the function goes out of scope everything is set back to 0?
any ideas on how i can keep a running balance inside a class?
The best way to attack this is with a static variable member....
Declare the variable static;
And its running value will not be reset to 0 when the object goes out of scope