09-02-2013, 02:25 PM
Programming in ANSI C ++
Programming in ANSI C ++.ppt (Size: 372.5 KB / Downloads: 18)
Identifiers and Constants (Literals)
The same set of rules for defining an identifier as C has
C++ identifier has no limit on significant length of the identifier (32 in C)
C++ supports all the literals, though there are some additions in ANSI C++.
Wide characters
L‘A’ as a wide character constant
This constant is wide, i.e., of 16-bit storage (so L precedes ‘A’)
Possible to accommodate characters in the Unicode format
Data Types
Data Types Borrowed from C
The data types void, int, char, float, and double operate in the same way as they do in C
The modifiers to all these types, i.e., signed, unsigned, long, and short work the same
Data Types Borrowed from C with Modifications
Some data types of C have been adapted to be compatible with C++.
These data types are structure, union, enumeration, and pointers
Newly Added Data Types
class is the central construct in ANSI C++.
Data types: Strings
Strings in C++ are much simpler to use than in C.
In C string is treated as character arrays, but ANSI C++ has a special string class for defining strings.
We need to include <string> to provide operations on strings.
A Pointer to Constant
A pointer to constant is a pointer variable that can point to any memory location, but the content of the memory location to which it points cannot be modified.
Placement new
The 'placement new' is one more form of new. It works in the following manner:
int* p = new int; II normal new
int* q = new (p) int; II placement new
No memory is allocated for the q variable here; its address is the same as p. It is useful in some special cases.