Hello Everyone,
I was wondering if anyone could show me how to call a function from inside a boolean statement. Something like the example below. I know it isn't right and was wondering if anyone could give me a hint or an example of coding it correctly. Thank you, hill0ster! :lol:

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;
        }
}
#include <iostream>
#include <cstdlib>
using namespace std; // for toy programs

bool getEmployeeData(int &ID)
{
   cout << "Enter employee ID: ";
   cin  >> ID;
   if ( ID >= 0 )
   {
	  return true;
   }
   return false;
}

int main()
{
   int id;
   if ( getEmployeeData(id) == false )
   {
	  cout << "*** Program Terminated ***" << endl;
	  exit (0);
   }
   cout << "id = " << id << endl;
   return 0;
}

Dave,
Thanks for your help. However I must call the bool isValidStatus from the bool getEmployeeData. If I had a choice I would call it from main. I have seen no examples of how to do this. If anyone knows how, I would much appreciate it. Paul.

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.