Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class A {
- public:
- explicit A(int n): n(n) {
- std::cout << "A(int) ctor: " << n << std::endl;
- }
- private:
- int n;
- };
- class B {
- public:
- B(int n): n(n) {}
- operator int() {return n;} // implicit conversion operator
- private:
- int n;
- };
- int main()
- {
- A x(5); // OK
- A y(B(15)); // why compiles?
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement