How to allocate memory
It can be allocated using HGLOBAL and HLOCAL
GlobalAlloc or LocalAlloc
In C you're usually using malloc()
and free()
While in C++ you use new
and delete
new
is used to allocate dynamic array
delete
is used to delete dynamic array
Fakherthe1,
Stick with standard C++ until some time, and, live the ugly code to it's designers and microsoft programers.
Static array can be allocated without using new
Dynamic arrays are allocated using new
codekiddy
What do u mean by that?
Static anything can be allocated without using new
.
Dynamic anything can be allocated using new
.
Arrays also need the square brackets, as coder777 mentioned above.
Fakherthe1,
I meant use clasic new
and new[]
to alocate memory for your objects.
Do you realy need HGLOBAL and HLOCAL?
I guess no, so leave them alone.
There are situations when you absolutely need HGLOBAL memory, such as interacting with windows clipboard.
new
and malloc
depends on CRT, it is possible to write a windows application without any depedencies on CRT (without statically linking in).
HGLOBAL and HLOCAL are used to allocated memory
for anything like integers,characters,images,vertices etc