mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
@@ -41,10 +41,10 @@ int main() {
|
||||
|
||||
// p2 is empty, no prints
|
||||
if(p2) p2->foo();
|
||||
std::cout << "p2 was destroied" << std::endl;
|
||||
std::cout << "p2 was destroyed" << std::endl;
|
||||
}
|
||||
// p1 is not empty, prints
|
||||
if (p1) p1->foo();
|
||||
|
||||
// Foo instance will be destroied when leaving the scope
|
||||
// Foo instance will be destroyed when leaving the scope
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ class A {
|
||||
public:
|
||||
std::shared_ptr<B> pointer;
|
||||
~A() {
|
||||
std::cout << "A was destroied" << std::endl;
|
||||
std::cout << "A was destroyed" << std::endl;
|
||||
}
|
||||
};
|
||||
class B {
|
||||
public:
|
||||
std::shared_ptr<A> pointer;
|
||||
~B() {
|
||||
std::cout << "B was destroied" << std::endl;
|
||||
std::cout << "B was destroyed" << std::endl;
|
||||
}
|
||||
};
|
||||
int main() {
|
||||
|
||||
Reference in New Issue
Block a user