|
-
December 10th, 2009, 04:01 PM
#1
calling a function within a function
Hello all i am currently working on an assignment and I am almost done with it. I'm having a bit of a hard time understanding the calling of a function within a function.
Here is some background to the program. It has generated randomly the phone number, age, credit card number, and has giving each employee a 1 (for secure) or 0 (for unsecured). I bascally have two functions print_secure and print_all. If the information is not secure it will display everything and if it is, it will display certain items.
Here is what I have so far.
Code:
void CustomerData::print_all()
{
int empNo;
cout << "Please enter the Employee Number: ";
cin >> empNo;
if (0 > empNo || empNo > 49) // checks to make sure that user entered value is within the limit [0 .. 49]
{
cout << "The Employee Number entered is out of bound. Please try again.\n";
return;
}
//Employee details are printed below
cout << "\nEmployee details\n";
cout << "----------------\n";
cout << "Employee Number: " << employees[empNo].empNo << "\n";
cout << "Employee Security Preference: " << employees[empNo].security_preference << "\n";
cout << "Age: " << employees[empNo].empAge << "\n";
cout << "Phone Number: " << employees[empNo].empphone << "\n";
cout << "Credit Card Number: " << employees[empNo].empCCNo << "\n";
cout << "\n\n";
}
/*void CustomerData::print_secure()
{
//Employee details are printed below
cout << "\nEmployee details\n";
cout << "----------------\n";
cout << "Employee Number: " << employees[empNo].empNo << "\n";
cout << "Employee Security Preference: " << employees[empNo].security_preference << "\n";
cout << "Employee Age: " << employees[empNo].empAge << "\n";
cout << "\n\n";
}*/
Since I don't want a classmate taking my code I only posted what I think is the main part I need help with.
I was thing of putting an if statement in void CustomerData:: print_all() to reference void CustomerData:: print_secure() but I don't have a clue as how to reference it. Could someone offer some advise?
Last edited by Fezzy; December 10th, 2009 at 04:03 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|