new-operator tag

4 questions


1 answers
123 views
0
Which one should I use, malloc or new?

In C++, there are many ways to dynamically allocate, right?Then when should I use malloc and when should I use new?malloc If you finished freeIf new is done, deleteI know I shouldn't mix the two.


1 answers
68 views
0
Does "new int[0]" allocate memory?

On my computer,cout << new int[0] << endl;When I ran , I printed 0x876c0b8.I think I'm allocating memoryAssigning [0] means assigning empty. Personally, I thought there would be an error, ...


1 answers
87 views
0
What's the difference between new and parentheses?

When you create an instance of the Test class that I define.What's the difference between the two?Is there a difference?


1 answers
62 views
0
Can I use "delete this"?

Can I write delete this; when I delete an instance of the class I created with new at the end?Write it like this. void doStuff(){ // This object is a working module // When you want to switch to anoth...


© 2024 OneMinuteCode. All rights reserved.