I wanted to do new because eventually what I want to do is something like this:
Code:
int main()
{
int selection;
string input;
bool goodinput = false;
while (goodinput == false)
{
cout << "Welcome to the employee database, what would you like to do?" << endl // prompt
<< "1. Add an employee" << endl << "2. Modify an employee" << endl;
getline(cin, input); //get input
stringstream(input) >> selection; //extract selection integer
if (selection == 1)
{
goodinput = true;
employees.push_back(create());
}
else if (selection == 2)
{
goodinput = false;
}
else
{
goodinput = false; // invalid selection - continue loop
cout << "Please enter a valid selection, 1 or 2." << endl;
}
}
return 0;
}
Also, if I explicitly call an instance of employee, like employee newemployee(name,payrate)...
Doesn't that instance only last for the scope of the function?
If not I don't need new at all, and I can just return a reference.