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.)

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.

commented: Yes indeed +17

yes

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

commented: You shouldn't have wasted your time spell checking it then ;) +17

lol, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.