...

/

Discussion: Off to a Good Start

Discussion: Off to a Good Start

Execute the code to understand the output and gain insights into function argument evaluation order and its implications.

Run the code

Now, it’s time to execute the code and observe the output.

Press + to interact
#include <iostream>
struct Logger {};
struct Configuration {};
Logger initializeLogger()
{
std::cout << "Initializing logger\n";
return Logger{};
}
Configuration readConfiguration()
{
std::cout << "Reading configuration\n";
return Configuration{};
}
void startProgram(Logger logger, Configuration configuration)
{
std::cout << "Starting program\n";
}
int main()
{
startProgram(initializeLogger(), readConfiguration());
}

Understanding the output

In this puzzle, we want to start a program that relies on a logger having been set up and a configuration having been read. As long as both of those are done before the program ...