Forums WoW Modding Support Archives WoWModding Support Archives [DiscordArchive] When should I delete a pointer?

[DiscordArchive] When should I delete a pointer?

[DiscordArchive] When should I delete a pointer?

Pages (3): 1 2 3 Next
rektbyfaith
Administrator
0
04-19-2022, 05:20 PM
#1
Archived author: Deleted User • Posted: 2022-04-19T17:20:01.094000+00:00
Original source

When should I delete a pointer?
rektbyfaith
04-19-2022, 05:20 PM #1

Archived author: Deleted User • Posted: 2022-04-19T17:20:01.094000+00:00
Original source

When should I delete a pointer?

rektbyfaith
Administrator
0
04-19-2022, 05:20 PM
#2
Archived author: Deleted User • Posted: 2022-04-19T17:20:11.164000+00:00
Original source

only when 'new' keyword is used? or every time I declare a pointer?
rektbyfaith
04-19-2022, 05:20 PM #2

Archived author: Deleted User • Posted: 2022-04-19T17:20:11.164000+00:00
Original source

only when 'new' keyword is used? or every time I declare a pointer?

rektbyfaith
Administrator
0
04-19-2022, 05:22 PM
#3
Archived author: <o> • Posted: 2022-04-19T17:22:10.372000+00:00
Original source

if you don't use the "new" keyword (or call some function that does it for you), you should not delete the pointer. Generally, it's better to use smart pointers and avoid "new" as much as possible
rektbyfaith
04-19-2022, 05:22 PM #3

Archived author: <o> • Posted: 2022-04-19T17:22:10.372000+00:00
Original source

if you don't use the "new" keyword (or call some function that does it for you), you should not delete the pointer. Generally, it's better to use smart pointers and avoid "new" as much as possible

rektbyfaith
Administrator
0
04-19-2022, 05:22 PM
#4
Archived author: Deleted User • Posted: 2022-04-19T17:22:57.808000+00:00
Original source

So, doing something like this:
`std::list<Unit*> targets;`
Would not require to delete?
rektbyfaith
04-19-2022, 05:22 PM #4

Archived author: Deleted User • Posted: 2022-04-19T17:22:57.808000+00:00
Original source

So, doing something like this:
`std::list<Unit*> targets;`
Would not require to delete?

rektbyfaith
Administrator
0
04-19-2022, 05:23 PM
#5
Archived author: Deleted User • Posted: 2022-04-19T17:23:16.917000+00:00
Original source

oh wait
rektbyfaith
04-19-2022, 05:23 PM #5

Archived author: Deleted User • Posted: 2022-04-19T17:23:16.917000+00:00
Original source

oh wait

rektbyfaith
Administrator
0
04-19-2022, 05:23 PM
#6
Archived author: <o> • Posted: 2022-04-19T17:23:18.386000+00:00
Original source

no, because you're not the one responsible for unit pointers. However, be very careful about storing entity references like that
rektbyfaith
04-19-2022, 05:23 PM #6

Archived author: <o> • Posted: 2022-04-19T17:23:18.386000+00:00
Original source

no, because you're not the one responsible for unit pointers. However, be very careful about storing entity references like that

rektbyfaith
Administrator
0
04-19-2022, 05:23 PM
#7
Archived author: Deleted User • Posted: 2022-04-19T17:23:25.464000+00:00
Original source

Yea
rektbyfaith
04-19-2022, 05:23 PM #7

Archived author: Deleted User • Posted: 2022-04-19T17:23:25.464000+00:00
Original source

Yea

rektbyfaith
Administrator
0
04-19-2022, 05:23 PM
#8
Archived author: Deleted User • Posted: 2022-04-19T17:23:36.846000+00:00
Original source

because the Unit pointer will be deleted when Unit gets destroyed
rektbyfaith
04-19-2022, 05:23 PM #8

Archived author: Deleted User • Posted: 2022-04-19T17:23:36.846000+00:00
Original source

because the Unit pointer will be deleted when Unit gets destroyed

rektbyfaith
Administrator
0
04-19-2022, 05:23 PM
#9
Archived author: Deleted User • Posted: 2022-04-19T17:23:37.873000+00:00
Original source

right?
rektbyfaith
04-19-2022, 05:23 PM #9

Archived author: Deleted User • Posted: 2022-04-19T17:23:37.873000+00:00
Original source

right?

rektbyfaith
Administrator
0
04-19-2022, 05:23 PM
#10
Archived author: <o> • Posted: 2022-04-19T17:23:50.783000+00:00
Original source

no, it will not, your pointers will be dangling and there is nothing you can do about that
rektbyfaith
04-19-2022, 05:23 PM #10

Archived author: <o> • Posted: 2022-04-19T17:23:50.783000+00:00
Original source

no, it will not, your pointers will be dangling and there is nothing you can do about that

Pages (3): 1 2 3 Next
Recently Browsing
 
Recently Browsing