Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- obj a;
- } // a is destroyed here
- {
- obj* b = new obj;
- }
- {
- FILE* pF = fopen( ... );
- // ... do sth with pF
- fclose( pF );
- }
- {
- std::fstream f( ... );
- // do sth with f
- } // here f gets auto magically destroyed and the destructor frees the file
- {
- string v( "bob" );
- string k;
- v = k
- // v now contains "bob"
- } // v + k are destroyed here, and any memory used by v + k is freed
- int main() {
- int a;
- auto int b;
- }
- auto a = std::max(1.0, 4.0); // `a` now has type double.
- MyObject x = MyObject(params); // onto the stack
- MyObject * y = new MyObject(params); // onto the heap
Add Comment
Please, Sign In to add comment