#include <iostream> #include <queue> #include <Windows.h>
using namespace std;
class CTask { public: CTask(const char* name, int goal) : goal(goal) { strcpy_s(taskName, name); } void Progress() { cout << taskName << "은(는" << ++pos << "으로 이동중입니다." << endl; Sleep(10); } bool isComplete() { return goal == pos; }
private: char taskName[100];
int pos{}; int goal{}; };
int main() { std::queue<CTask*> taskQue;
CTask task1("작업1", 100); CTask task2("작업2", 150); CTask task3("작업3", 200);
taskQue.push(&task1); taskQue.push(&task2); taskQue.push(&task3);
while (!taskQue.empty()) { CTask* task = taskQue.front(); task->Progress(); if (task->isComplete()) { taskQue.pop(); cout << "다음 작업 대기중.\n"; Sleep(1000); } } cout << "작업 완료.\n"; } |