Advertisement
kanagara

Smart pointer- unique pointer error

Feb 21st, 2021 (edited)
1,279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <memory>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     double* broj = new double(10);
  9.    
  10.     unique_ptr<double> uptr2 (broj);
  11.     /* Zabranjeno je referencirati isti pokazivac preko unique_pointera!
  12.     Ovako mali program ce moci da se izvrsi do kraja, uz gresku, ali u kompleksnijim aplikacijama, ovo moze biti    
  13.     ozbiljniji problem */
  14.     unique_ptr<double> uptr3 (broj);
  15.  
  16.     cout << "Zdravo";
  17.  
  18.     return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement