Memory management scope in C/C++ -


when freeing memory in c , c++, need memory address or require specific variable?

so if such as:

int* test() {     int* x = new int(5);     return x; }  int main(int argc, char** argv) {     int* y = test();      delete y;      return 0; } 

would cause memory leaks? thanks!

no, there wouldn't leaks there, again, neither there in

int test() {     return 5; }  int main(int argc, char** argv) {     int y = test();     return 0; } 

avoid dynamic allocation if can.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -