Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. namespace std {class auto_ptr{}; class unique_ptr{}; class shared_ptr{} ; }
  2. #include <iostream>
  3.  
  4. struct A { int i = 1; };
  5.  
  6.  
  7. int main() {
  8.   const ptr<A> a(new A);
  9.   const ptr<A> b;
  10.   ptr<A> c(new A);
  11.  
  12.   ptr<A> _b_error = new A; // Odkomentowanie powoduje błąd kompilacji
  13.   //a = a;                  // Odkomentowanie powoduje błąd kompilacji
  14.   const ptr<A> _c_error = a;  // Odkomentowanie powoduje błąd kompilacji
  15.   // std::cout << ((*a).i, a->i) << " "<< ++c -> i << " ";
  16.   // std::cout << (a == ptr<A>() ) << " " << (a != b) << "'\n";
  17. }
  18. /* output/wyjście:
  19. 1 2 0 1
  20. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement