O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declarations

The first difference you’ll read about is something that you’ve been insulated from so far and has to do with void pointers. Recall, for example, that you can allocate memory blocks in C using the malloc function, which returns a void pointer.

In C, this means that you can, in theory, write code such as:

char * szString;
szString = malloc ( String_Length * sizeof(char) );

The discussion of memory management used an explicit, rather than an implicit, conversion from void * to char *. This leads you to write code such as:

char * szString;
szString = (char * ) malloc ( String_Length * sizeof(char) );

This second representation is required in C++, which largely does away with implicit type conversion in favor of improved type checking. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required