In C++, we often want to print objects directly to the console or a log stream using std::cout << obj, rather than calling a specific method like obj.print(). To achieve this, we must overload the << operator. Since the << operator is a global function (the left side is std::ostream, not our class), it cannot be a member function. Therefore, it must be declared as a Friend to access the private data it needs to print.
Your task is to implement a class SystemStatus.
Private members: int code, std::string message.
Constructor to initialize them.
Friend Function: Overload operator<< to print the object in the format: [Status: <code>] <message>.
Program Flow:
Read integer N.
Loop N times.
Read integer code and string msg.
Instantiate a SystemStatus object.
Print it using std::cout << obj << std::endl;.
Input Format:
First line: Integer N.
Next N lines: Integer code, followed by string msg.
Input is provided via standard input (stdin).
Output Format:
[Status: <code>] <message>
Each output must be on a new line.
Example:
Example 1
Input:
2
404 NotFound
200 OK
Output:
[Status: 404] NotFound
[Status: 200] OK
Constraints:
Must use friend std::ostream& operator<< ....
Must return the stream object (os) to allow chaining.