1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

*

There are three equivalent ways of making a non-default size stack:

Istack s1(500); Istack s1 = 500; Istack s1 = {500};

// or // or

*

Here are some other equivalent declarations:

char s[] = "hello"; char s[] = {"hello"}; char* s = "hello"; char* s = {"hello"};

// or // or
// or

int i = 5; int i(5); int i = {5};

// or
// OK, logical, but g++ says not

new and delete vs. malloc() and free()

If T is some type in your program (char, int, double, or some struct or class) and

T* tp;

then

tp = new T;

// equivalent to:

tp = (T*) malloc (sizeof (T));

Note the need for explicit type conversion here.

16-Mar-98

Page 12

C201/TAM/AGS