#include <iostream>
#include <thread>
#include <string>
#include <chrono>
class Stamgasten {
public:
int num; //number
std::string nam; //name
std::string gen; //gender
std::string utt; //utterance
// Constructor
Stamgasten(int num, std::string nam, std::string gen, std::string utt) {
this->num = num;
this->nam = nam;
this->gen = gen;
this->utt = utt;
}
// Method
void talk() {
std::cout << nam << " zei: " << utt << std::endl;
}
};
// Function for threads
void gastTalk(Stamgasten gast) {
gast.talk();
}
int main() {
Stamgasten s1(1, "Jan", "male", "Hallo Luitjes.");
Stamgasten s2(2, "Marie", "female", "Goedenavond.");
Stamgasten s3(3, "Piet", "male", "Oioi - en we nemen er nog een!");
Stamgasten s4(4, "Kim", "unknown", "Dag mensen.");
Stamgasten s5(5, "Klaas", "male", "What's up?");
std::thread t1(gastTalk, s1);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::thread t2(gastTalk, s2);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::thread t3(gastTalk, s3);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::thread t4(gastTalk, s4);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::thread t5(gastTalk, s5);
t1.join();
t2.join();
t3.join();
t4.join();
t5.join();
return 0;
}