1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> using namespace std; class A { public: A(){} private: A(const A&) {} }; //source of error : pass by value void f(A) {} int main() { A a; f(a); return 0; } |
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIEEKewpwdWJsaWM6CiAgICAgQSgpe30KcHJpdmF0ZToKICAgICBBKGNvbnN0IEEmKSB7fQp9OwoKLy9zb3VyY2Ugb2YgZXJyb3IgOiBwYXNzIGJ5IHZhbHVlCnZvaWQgZihBKSB7fQoKaW50IG1haW4oKSB7CglBIGE7CiAgICAgICAgZihhKTsKCXJldHVybiAwOwp9
prog.cpp: In function ‘int main()’: prog.cpp:10: error: ‘A::A(const A&)’ is private prog.cpp:18: error: within this context prog.cpp:18: error: initializing argument 1 of ‘void f(A)’
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


