Question 8
Back to Exercise
What is the output of the following C++ program on a 64-bit system?
#include <iostream>
#include <string>
struct Options {
std::string format = "pdf";
int copies = 1;
bool color = false;
double scale = 1.0;
};
int main() {
Options a{};
Options b{.copies = 3, .scale = 0.5};
Options c{.format = "png", .color = true};
std::cout << a.format << a.copies << a.color << ' ' << b.format << b.copies << b.color << b.scale << ' ' << c.format << c.copies << c.color << '\n';
return 0;
}
- A pdf10 pdf300.5 png11 Correct
- B pdf10 300.5 png11
- C pdf10 pdf30 png11
- D pdf11 pdf300.5 png01
Correct Answer: Option A
Members that are not named keep their default member initialisers.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!