목록C++/따배C++ 10강 객체들 사이의 관계 (4)
일상 코딩
1. main.cpp #include "Worker.h" // using namespace std; int main() { Worker().doSomething(); return 0; } 2. Timer.h #pragma once #include #include #include #include #include class Timer { private: using clock_t = std::chrono::high_resolution_clock; using second_t = std::chrono::duration; std::chrono::time_point start_time = clock_t::now(); public: void elapsed() { std::chrono::time_point end_tim..
#include #include #include using namespace std; class Doctor; // forward declaration class Patient { private: string m_name; vector m_doctors; public: Patient(string name_in) : m_name(name_in) { } void addDoctor(Doctor *new_doctor) { m_doctors.push_back(new_doctor); } void meetDoctors(); friend class Doctor; }; class Doctor { private: string m_name; vector m_patients; public: Doctor(string name_..
1. main #include #include #include "Lecture.h" int main() { using namespace std; std::string lec_title1("Introduction to Computer Programming"); std::string lec_title2("Computational Thinking"); Student *std1 = new Student("Jack Jack", 0); Student *std2 = new Student("Dash", 1); Student *std3 = new Student("Violet", 2); Teacher *teacher1 = new Teacher("Prof. Hong"); Teacher *teacher2 = new Teach..