User Tools

Site Tools


Sidebar

Dan's Wiki

DokuWiki Instructions (local) DokuWiki Manual
Site Checker (Orphans Wanted)

Edit Sidebar

programming:cplusplus:start

This is an old revision of the document!


C++ Notes and Information

Helpful tutorials on YouTube are by TheChernoProject https://www.youtube.com/channel/UCQ-W1KE9EYfdxhL6S4twUNw

Memory

There are two areas of memory, Stack, and Heap.

StackWhen scope for variable ends, the memory is freed.
HeapStays there until manually removed with delete

new keyword

The new keyword allocates memory from the Heap. It returns a pointer to it. The number of bytes to allocated is determined by the argument. int provides 4 bytes, for example.

int * a = new int;
 
*a = 2;
 
std::cout << *a << std::endl;
int * a = new int;
// is nearly identical to this:
int * a = malloc(4);

Visual Studio Formatting/Indenting C++ code

Use Control-K, followed by Control-F. 7/5/2019

programming/cplusplus/start.1570799785.txt.gz · Last modified: 2019/10/11 13:16 by dwheele