1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// shared_ptr::get example
#include <iostream>
#include <memory>
int main () {
int* p = new int (10);
std::shared_ptr<int> a (p);
if (a.get()==p)
std::cout << "a and p point to the same location\n";
// three ways of accessing the same address:
std::cout << *a.get() << "\n";
std::cout << *a << "\n";
std::cout << *p << "\n";
return 0;
}
| |