View Single Post
Old 12-21-2004, 12:20 PM   #9 (permalink)
Yakk
Wehret Den Anfängen!
 
Location: Ontario, Canada
malloc and 'free' exists in C++. You can use 'new' and 'delete' instead, however.

int* x = new int[10] makes an array of 10 ints.

delete[] x;
deletes the array pointed to by x.

new and delete call constructors, while malloc and free do not. This is more important when you are writing real C++ code.

std::vector's are what you want for dynamic arrays in C++. Really.
__________________
Last edited by JHVH : 10-29-4004 BC at 09:00 PM. Reason: Time for a rest.
Yakk is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62