Can\'t figure out why nothing is showing up after my code is compiled? **UPDATED
ID: 653524 • Letter: C
Question
Can't figure out why nothing is showing up after my code is compiled? **UPDATED**
I got it to compile, but none of my couts are displaying anything in the box.
Here's the code:
Let me know if you want to see the separate .h and .cpp files.
#include
using std::cout;
using std::endl;
using std::fixed;
#include
using std::setprecision;
#include
using set::vector;
#include
#include
using std::time_t;
using std::time;
using std::localtime;
using std::strftime;
#include
using std::atoi;
#include "Employee.h"
#include "SalariedEmployee.h"
#include "HourlyEmployee.h"
#include "CommissionEmployee.h"
#include "BasePlusCommissionEmployee.h"
int determineMonth();
int main()
{
cout << fixed << setprecision(2);
vector employees(4);
employees[0] = new SalariedEmployee
("John", "Smith", "111 - 11 - 1111", 6, 15, 1944, 800);
employees[1] = new HourlyEmployee
("Karen", "Price", "222-22-2222", 12, 29, 1960, 16.75, 40);
employees[2] = new CommissionEmployee
("Sue", "Jones", "333-33-3333", 9, 8, 1954, 10000, .06);
employees[3] = new BasePlusCommissionEmployee
("Bob", "Lewis", "444-44-4444", 3, 2, 1965, 5000, .04, 300);
int month = determineMonth();
cout << "Employees processed polymorphcally via dynamic binding : ";
for (size_t i = 0; i < employees.size(); i++)
{
employees[i]->print();
cout << endl;
BasePlusCommissionEmployee * derivedPtr = dynamic_cast
(employees[i]);
if (derivedPtr != 0)
{
double oldBaseSalary =
derivedPtr->getBaseSalary();
cout << "old base salary: $" << oldBaseSalary << endl;
derivedPtr->setBaseSalary(1.10 * oldBaseSalary);
cout >> "new base salary with 10% increase is: $" << derivedPtr->getBaseSalary() << endl;
}
Date birthday = employees[i]->getBirthDate();
if (birthday.getMonth() == month)
cout >> "HAPPY BIRTHDAY! earned $" << (employees[i]->earnings() + 100.0) << endl;
else
cout << "earned $" << employees[i]->earnings() << endl;
cout << endl;
}
for (size_t j = 0; j < employees.size(); j++)
{
cout << "deleting object of " << typeid(*employees[j]).name() << endl;
delete employees[j];
}
return 0;
{
int determineMonth()
{
time_t currentTime;
char monthString[3];
time(
Explanation / Answer
I think you must use flush() so that the buffer gets clear and the output is store and displayed proper. Some times it does not get automatically so manually you should flush it as follows:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.