Getting Started:
Demonstrate how to build an Application with Tasks
/////////////////////////////////////////////////////////////////////
// Task3.cpp - second task for GettingStarted application
//
#include "Task3.h"
#include <iostream>
#include <iostream>
#include <fstream>
/*----< initialize Task2 instances >-------------------------------*/
Task3::Task3()
{
std::cout << "\n Starting Task3";
}
/*----< return resources used by Task2 instances >-----------------*/
Task3::~Task3()
{
std::cout << "\n Task3 shutting down";
}
/*----< execute Task2 activities >---------------------------------*/
void Task3::doWork()
{
std::cout << "\n performing Task #3 -- attempts to open non-existing file";
std::string fileName = "doesntExist";
std::ifstream strm;
// c++ streams won't throw exceptions unless you tell them to do so
strm.exceptions(std::ifstream::failbit | std::ifstream::badbit);
strm.open(fileName);
char byte;
byte = strm.get();
}
/*----< implement required self-test >-----------------------------*/
bool Task3::test()
{
doWork();
return true;
}
/*----< entry point simply invokes its own self-test >-------------*/
#ifdef TEST_TASK3
int main()
{
std::cout << "\n testing Task3";
std::cout << "\n ---------------";
Task3 t3;
t3.testPackage();
std::cout << "\n\n";
}
#endif