//Hi all,could someone explain the make_shared(), is it used to substitute constructor?
//Here is an example
void DoAddStaff(vector<Ptr>& container)
{
cout << "\nEnter type of employee to add ('W' for waged, 'S' for salaried): ";
char c;
cin >> c;
cin.ignore();
if( c == 'w' || c == 'W' )
{
cout << "\nEnter waged employee's name: ";
string name;
getline(cin, name);
cout << "\nEnter waged employee's hourly rate of pay: ";
double rate;
cin >> rate;
cin.ignore();
container.push_back( make_shared<CWagedEmployee>(name, CreateEmplNum( container ), rate) );
}
else if( c == 's' || c == 'S' )
{
cout << "\nEnter salaried employee name: ";
string name;
getline(cin, name);
cout << "\nEnter employee's salary: ";
double salary;
cin >> salary;
container.push_back( make_shared<CSalariedEmployee>(name, CreateEmplNum( container ), salary) );
}
else
cout << "Wrong type." << endl;
aluhnev 0 Junior Poster in Training
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.