Is there a way to create an array of Ptr<> objects?

8 views
Skip to first unread message

richard

unread,
Nov 20, 2019, 9:12:35 PM11/20/19
to ns-3-users
I want to create an array of Ptr<Packets> however if I do not allocate the array once it goes out of scope I lose the reference to the Packets.

I found a way to do it but then I had to clean the memory manually myself:

Ptr<Packet> * ptr = new Ptr<Packet>[10];
...
// Once I finish I delete the array of Ptr<Packets>
delete[] ptr;

Is there a way to do define an array of Ptr<> objects so that they get cleaned automatically?
Reply all
Reply to author
Forward
0 new messages