Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- class A
- {
- int a;
- static int f;
- public:
- int get_a() {
- return a;
- }
- A (const A &y) {
- std::cin>>a;
- a += y.get_a();
- }
- A () {
- std::cin>>a;
- f = 1;
- }
- ~A () {
- if (f) {
- std::cout<<a<<std::endl;
- f = 0;
- }
- }
- };
- int A::f=0;
- Compilation error
- 000242.cpp: In copy constructor 'A::A(const A&)':
- 000242.cpp:14:22: error: passing 'const A' as 'this' argument discards qualifiers [-fpermissive]
- 14 | a += y.get_a();
- | ^
- 000242.cpp:9:9: note: in call to 'int A::get_a()'
- 9 | int get_a() {
- | ^~~~~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement