[ create a new paste ] login | about

Link: http://codepad.org/ASHNEv2O    [ raw code | output | fork ]

DigitalGhost - C++, pasted on Dec 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class foo {
  friend int lvalue_only(foo &);
  int f() const {
    return 1;
  }
};

int lvalue_only(foo & x) {
  return x.f();
}

int main() {
  foo x;
  lvalue_only(x);
  lvalue_only(foo());
}


Output:
1
2
3
In function 'int main()':
Line 16: error: invalid initialization of non-const reference of type 'foo&' from a temporary of type 'foo'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: