1. (Explicit Constructors) Consider the following class: struct B { explicit B(int) {} explicit B(int, int) {}...
Question:
1. (Explicit Constructors)
Consider the following class:
struct B
{
explicit B(int) {}
explicit B(int, int) {}
explicit operator int() const { return 0; }
};
Create a program to test the class. Which lines of code below compile and which ones do not? How would you modify the class to ensure that they do compile? Otherwise, how can these lines be modified so that the code compiles error free without modifying the class?
B b1 = 1;
B b2(3);
B b3{ 7,3 };
B b4 = (B)42;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Question Posted: