0

If you use the new operator on a class, say

class dummy { public: string f; };
int main(int argc, char *argv[]) {
  dummy *p = new dummy;
  return 0;
}

do you have to use the delete operator on p ? (since, apparently, it utilizes new.)

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by hacker9801
1

If you use the new operator on a class, say

class dummy { public: string f; };
int main(int argc, char *argv[]) {
  dummy *p = new dummy;
  return 0;
}

do you have to use the delete operator on p ? (since, apparently, it utilizes new.)

Yes, when you want to release that memory, 'delete' needs to be issued.

Votes + Comments
Yes indeed
1

yes

[edit] damn, even with only 1 word to type, mitrmkar beat me to it

Votes + Comments
You shouldn't have wasted your time spell checking it then ;)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.