Created
September 19, 2013 23:50
-
-
Save redotics/6631457 to your computer and use it in GitHub Desktop.
This show that destructor is called on object at end of the block where they were called. With valgrind you could also see that the 42 allocated ints (42*4=168 bytes) are still here --> LEAK SUMMARY: definitely lost: 168 bytes in 1 blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdlib.h> | |
class Monstre { | |
public: | |
Monstre() { A = (int*)malloc(sizeof(int)*42); } | |
~Monstre() { std::cout << "iDestroy the new way of iPhoning." << std::endl; } | |
private: | |
int* A; | |
}; | |
int main() { | |
int a = 5; | |
if (a > 3) { | |
Monstre Alf; | |
std::cout << "In the main, doing nothing" << std::endl; | |
} | |
std::cout << "Program over." << std::endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment