Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
struct A
{
A(int& var) : r(var) {}
int &r;
};
int main(int argc, char** argv)
{
int x = 23;
A a1(x);
A a2 = a1;
a2 = a1;
return 0;
}
/**
main.cc: In function 'int main(int, char**)':
main.cc:17:9: error: use of deleted function 'A& A::operator=(const A&)'
a2 = a1;
^~
main.cc:2:8: note: 'A& A::operator=(const A&)' is implicitly deleted because the default definition would be ill-formed:
struct A
^
main.cc:2:8: error: non-static reference member 'int& A::r', can't use default assignment operator
**/
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content