jeudi 20 octobre 2016

What is the difference between *ptr and *ptr.get() as a auto_ptr?

Why do I use get() instead of calling "*" at least?

  auto_ptr<int> p (new int);
  *p = 100;
  cout << "p points to " << *p << '\n';         //100

  auto_ptr<int> p (new int);
  *p.get() = 100;
  cout << "p points to " << *p.get() << '\n';   //100

Result is excatly the same. Is it more secure?

Aucun commentaire:

Enregistrer un commentaire