This example was taken from §8.5.3/5 (first bullet point) in the C++11 Standard:
struct A { };
struct B : A { operator int&(); } b;
int& ri = B();
If it does, is there any way to access the temporary B()
, in the code below?
#include <iostream>
struct A { };
struct B : A { int i; B(): i(10) {} operator int&() { return i; } } b;
int main()
{
int& ri = B();
std::cout << ri << '\n';
}