need help, what I need to do is have the status function run before each withdrawl to let the user know if the account is active or inactive. Active = balance > 25, if account balance <25 then no withdrawls can occur. I have the following:

#include <iostream>
#include "Savings.h"
using namespace std;

bool Savings::withdraw(double amount)
{
if (balance < amount)
return false; //not enough in the account
else
{
balance -= amount;
transactions++;
return true;
}
}

void Savings::status(bool active)
{
if (balance > 25)
{
bool active = true;
cout << "Account is active\n";
}

else
{
bool active = false;
cout << "Account is inactive\n";
}

}

in generic.cpp I have:

int main()
{
Generic check; //object of Generic class created
Savings save; //object of Savings class created
CharRange input ('A', 'I'); //object of CharRange class created, will check for chars A-G
char choice;

save.status(true);

void withdraw(Savings &savings)
{

bool save;

double dollars;
cout << "Enter the amount of the withdrawl: ";
cin >> dollars;
cin.ignore();
if(!savings.withdraw(dollars))
cout << "ERROR: Non-sufficient funds.\n\n"; save.status(); }

Can you add a private bool member to your savings class and simply use your status method to set it or unset it? You could have a "getter" to check it when the need arose. So in your withdrawal case, it would be savings.status(false);

Also, put code tags around everything before your half-hour runs out and it's stuck hehe

ok, thank you, it worked! not sure what you mean about code tags and half-hour, i am fairly new to this site...hm.

now, I need the function status to be ran after the user does a withdrawl, i got that part but I am trying to write if/else stmt for if account is inactive then have it say account is inactive and not allow the "cout << "Enter the amount of the withdrawl: "; to execute.

this is what i have and get error "active" being used without being initialized, so i initialized but then the balance remains same even about i keep adding deposits:

void withdraw(Savings &savings)
{   
    int balance;
    double dollars;
    bool active;
    int account;
    savings.status(false);
    if (account = active)
    {
        cout << "Enter the amount of the withdrawl: ";
        cin >> dollars;
        cin.ignore();
    }
    else 
    {
        if(!savings.withdraw(dollars))
        cout << "ERROR: Non-sufficient funds.\n\n";
    }


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.