I am currently studying C++ as a beginner. There is this program that simulates a printing queue but I don't quite understand what the code means inside the class that contains data members.
#include <iostream>
#include <queue>
class Job
{
int id;
std::string user;
int time;
static int count;
public:
Job(const std::string &u, int t) : user(u), time(t), id(++count)
{
}
friend std::ostream &operator<<(std::ostream &os, const Job &j)
{
os << "id: " << j.id << ", user: " << j.user << ", time: " << j.time << " seconds" << std::endl;
return os;
}
};
Can anybody explain what's happening in that code below? I don't understand what the code such as below does:
Job(const std::string &u, int t) : user(u), time(t), id(++count)