Advertisement
Guest User

Untitled

a guest
May 2nd, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. A gcc compilation error (concerning copy c'tors) which seems odd (at least to me)
  2. testref.cpp: In function β€˜int main()’:
  3. testref.cpp:10: error: β€˜A::A(const A&)’ is private
  4. testref.cpp:20: error: within this context
  5.  
  6. #include <cstdio>
  7.  
  8. class A {
  9. public:
  10. A() { i=0; printf("A ctorn"); }
  11. ~A() { printf("A dtorn"); }
  12.  
  13. private:
  14. A(const A& other) { i=other.i; printf("A COPY CTORn"); }
  15. A& operator=(const A& other) { i=other.i; printf("A COPY operatorn"); return *this; }
  16. private:
  17. int i;
  18. };
  19.  
  20. void f(const A &aref) {
  21. printf("dummyn");
  22. }
  23.  
  24. int main() {
  25. f(A());
  26. return 0;
  27. }
  28.  
  29. test.cpp:20:7: warning: C++98 requires an accessible copy constructor for class
  30. 'A' when binding a reference to a temporary; was private
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement