I have never seen an example of this, but I need to call a function or another bool from inside a bool! If anyone knows how this might go, please let me know. P.S. This website is awsome! Thanks, Paul
//something like this, however this is not working...

bool getEmployeeData(int ID)
{
    cout << "Enter employee ID: " << endl;
    cin >> ID;

        if (ID >= 0)
        {   
            return true;
            bool isValidStatus;

        }

        else
        {   
            cout << "*** Program Terminated ***" << endl;
            exit (0);
            return false;
        }
}

bool isValidStatus (int status)
{
    cout << "Enter payroll status: " << endl;
    cin >> status;

    if (status == 's' || status == 'S' || status == 'c' || status == 'C' || status == 'h' || status == 'H')
    {
        cout << status;
        return tryAgain;
    }

    else
    {
        bool tryAgain (int quit);
        return false;
    }
}

>but I need to call a function or another bool from inside a bool!
Work on your terminology first, because I have no clue what you want. Let's get this straight, bool is a type. bool has two values: true and false. You don't call squat from inside a bool because all it does is represent true or false, nothing else. You can have functions that return bool, or statements that result in bool, but they're not bool and shouldn't be referred to as such if you want to have meaningful conversation with intelligent parties.

Yes, you can call other functions from inside a bool. I may be a newbie, but I would appreciate some respect if you respond to me! Otherwise don't bother responding.

I do not really understand the problem that you have. But a few explanations might help

if (ID >= 0) {
    return true;            // you're returning from the call here
    bool isValidStatus;     // this statement is never reached
                            // here you are declaring a boolean variable isValidStatus. 
                            // this is not a call to the function of the same name;
}
else{
    cout << "*** Program Terminated ***" << endl;
    exit (0);              // same problem is here. the prog is terminated here
    return false;          // this statement is never reached
}

maybe you want something like this

#include <iostream>
using namespace std;

bool isValidStatus( char status ) {
  if (status == 's' || status == 'S' || status == 'c' || status == 'C' || status == 'h' || status == 'H'){
    return true;
  }
  cout << status << " is not valid ! try again" << endl;
  return false;
}

char getStatus() {
  char status;
  do {
     cout << endl << "Enter payroll status: ";
     cin >> status;
  } while ( ! isValidStatus(status) ); // repeat until a valid status is entered
  return status;
}

int getEmployeeData() {
  int ID = 0;
  cout << "Enter employee ID (0 to exit program ): ";
  cin >> ID;
  if ( ID == 0 ) {
    cout << "bye.." << endl;
    exit (0);     
  }         // terminate program
  cout << "employee ID= " << ID << endl;
  return ID;
}

int main() {
   int ID = getEmployeeData();   // read employee ID
   char status = getStatus();    // read Status
   cout << "the status entered was : " << status << endl; 
   return 0;              // main should return an exit-code
}

Hope this helps.
btw. Naru seems to be here to insult people.
K.

>Yes, you can call other functions from inside a bool.
Then you're not using the proper terminology. A bool is true or false, that's it. There's no way to call a function from inside a value. I suspect that what you're thinking of is calling a function in a conditional test:

#include <iostream>

using namespace std;

bool f()
{
  // Do something and return true or false
}

int main()
{
  if ( f() )
    cout<<"f() was true"<<endl;
}

or calling a function that returns bool from another function that returns bool:

#include <iostream>

using namespace std;

bool f1()
{
  // Do something and return true or false
}

bool f2()
{
  if ( f1() && something else )
    return true;
  else
    return false;
}

int main()
{
  if ( f() )
    cout<<"f() was true"<<endl;
}

>but I would appreciate some respect if you respond to me!
I do respect you for various reasons, but I don't respect your complete lack of an attempt to express yourself in a way that is conducive to getting help. I'm not going to guess what you want simply because you don't know how to ask the question in a way that we can understand. So let's go over this one more time.

A bool is a data type with two values. Functions can return bool, expressions can result in bool, but the only thing that can be inside bool is true or false that map to non-zero and zero integral values, respectively. Tell me how to call a function from within 0 and I'll reconsider this explanation.

>btw. Naru seems to be here to insult people.
I'm not responsible for your misconceptions. Though I don't like the insinuation that I don't help people here.

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.