C++ Quick Syntax Reference by Mikael Olsson

C++ Quick Syntax Reference by Mikael Olsson

Author:Mikael Olsson [Olsson, Mikael]
Language: eng
Format: epub, pdf
Tags: C, Computers, Programming, Microsoft, Programming Languages
ISBN: 9781430262770
Publisher: Apress
Published: 2013-07-31T04:00:00+00:00


New initialization

Finally, an object can be initialized through dynamic memory allocation by using the new keyword. Dynamically allocated memory must be used through a pointer or reference. The new operator returns a pointer, so to assign it to a reference it needs to be dereferenced first. Keep in mind that dynamically allocated memory must be explicitly freed once it is no longer needed.

// New initialization

MyClass* a = new MyClass();

MyClass& b = *new MyClass();

// ...

delete a, b;

CHAPTER 14



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.