Skip to content

Commit c8dc81f

Browse files
committed
fix mistakes
1 parent 0f05ccd commit c8dc81f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

content/posts/cpp-for-cscharp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ What makes this one different from the other smart pointers:
126126
void test()
127127
{
128128
// making a unique pointer
129-
unique_ptr<Foo> foo_ptr = make_unique<Foo>(new Foo());
129+
std::unique_ptr<Foo> foo_ptr = std::make_unique<Foo>();
130130

131131
// No need to delete, gets freed at end of scope
132132
}
@@ -149,10 +149,10 @@ What makes this one different from the other smart pointers:
149149
void test()
150150
{
151151
// making a shared pointer
152-
shared_ptr<Foo> sp_1 = make_shared<Foo>(new Foo());
152+
std::shared_ptr<Foo> sp_1 = std::make_shared<Foo>();
153153

154154
// sharing ownership
155-
shared_ptr<int> sp_2 = sp_1;
155+
std::shared_ptr<int> sp_2 = sp_1;
156156

157157
// get amount of shares
158158
int shares = sp_1.use_count() // there are now 2 shares
@@ -188,10 +188,10 @@ What makes this one different from the other smart pointers:
188188
void test()
189189
{
190190
// making a shared pointer
191-
shared_ptr<Foo> sp = make_shared<Foo>(new Foo());
191+
std::shared_ptr<Foo> sp = std::make_shared<Foo>();
192192

193193
// sharing ownership but with weak pointer
194-
weak_ptr<Foo> wp = sp;
194+
std::weak_ptr<Foo> wp = sp;
195195

196196
// get amount of shares
197197
int shares = sp.use_count() // still 1, weak ptr didnt add a share

0 commit comments

Comments
 (0)