blob: ea80a3fa6b91961a5bc028a7880248b96d9de416 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
class X // Indentation has been done so to see the similarities.
{
public:
X() {} // ERROR - referenced below
X(X& x) {x.i=7;} // ERROR - Both functions modify the
void bar(X& x) {x.i=7;} // ERROR - reference parameter x.
int i;
};
X foo() { X x; return x; }
main()
{
X x(foo()); // ERROR - Compiler doesn't warn about temporary reference.
x.bar(foo()); // ERROR - The same mistake is warned about in this case.
}
|