From c1353e6e2ec3aededc653e50516a2e35ec3ef241 Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Sun, 15 Mar 2020 22:16:54 +0200 Subject: Update 3. weak_ptr.cpp --- Smart_pointers/3. weak_ptr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Smart_pointers/3. weak_ptr.cpp b/Smart_pointers/3. weak_ptr.cpp index 802cb51..044985a 100644 --- a/Smart_pointers/3. weak_ptr.cpp +++ b/Smart_pointers/3. weak_ptr.cpp @@ -41,9 +41,9 @@ int main() cout << smart_pointer_2.use_count() << endl; // 1 - weak_ptr НЕ участва в бройката на пойнтерите към обектите. //smart_pointer_2->f(); ГРЕШКА! - //Това е само за временен достъп! Ако искате да достъпите данните на този пойнтер трябва да го превърнете в shared_ptr!. + //Това е само за временно пазане на адреса! НЕ МОЖЕМ да достъпим данните. Ако искате да достъпите данните на този пойнтер трябва да го превърнете(заключте) в shared_ptr!. - shared_ptr smart_pointer_3 = smart_pointer_2.lock(); + shared_ptr smart_pointer_3 = smart_pointer_2.lock(); //.lock() връща shared_ptr към обекта. cout << smart_pointer_1.use_count() << endl;//2 -- cgit v1.3.1-23-gd82d