/////////////////////////////////////////////////////////////// // MT1-Q5b.cpp - pass messages to child thread // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2019 // /////////////////////////////////////////////////////////////// #include #include #include #include void threadProc(const std::vector& vecStr) { for(auto str : vecStr) std::cout << "\n " << str.c_str(); } int main() { std::cout << "\n MT1-Q5b - thread accepting string messages"; std::cout << "\n --------------------------------------------"; // This is not nearly as useful as MT1-Q5, as it hands the child thread // all its messages when it starts. std::vector vecStr { "first string message", "second string message", "third string message" }; std::thread t(threadProc, vecStr); t.join(); std::cout << "\n\n"; }