Basic Features

Dependencies

Comments
C++ introudces a new comment symbol //(double slash). Comments start with a double slash symbol and terminate at the end of the line.Note there is no closing symbol.
* The double slash comment is basically a single line comment. Single line comments can be written as follows:-
// C++ New comments features.
* The C comment symbols/* text */ are still valid and more suitalble for multilne comments. Multiline comments can be written as follows:-
/* The is an example to show
feature of C comment symbols
used in c++ */
Header Files
iostream file
#include < iosteam > This directive causes the preprocessor to add the contents of the iostream file to the program. It contains declarations for the identifier cout and the operator <<. Some old verisons of C++ use a header file called iosteam.h. This is one of the changes intruduced by ANSI c++.(We should use iostream.h if the compiler does not support ANSI C++ features.)
Header File Contents and purpose New version
< assert.h > Contains macros and information for adding diagnostics that aid program debugging < cassert >
< ctype.h > Contains function prototypes for functions that test characters for certain properties, and function prototypes for functions that can be used to convert lowercase letters to uppercase letters vice versa. < cctype >
< float.h > Contains the floating-point size limits of the system. < cfloat >
< limits.h > Contains the integral size limits of the system < climits >
< math.h > Contains function prototypes for math library functions < cmath >
< stdio.h > Contains function prototypes for the standard input/ output library functions and information used by them. < cstdio >
< stdlib.h > Contains function prototypes for conversion of numbers to text, text to numbers, memory allocation, random numbers, and various other utility functions. < cstdlib >
< string.h > Contains function prototypes for C-style string processing functions. < cstring >
< time.h > Contains function prototypes and types for manipulating the time and date.
< iosteam.h > Contains function prototypes for the standard input and standard output functions. < iostream >
< iomanip.h > Contains function prototypes for the stream manipulates that enable formatting of streams of data. < iomanip >
< fstream.h > Contains function prototypes for functions that perform input from files on disk and output to files on disk < fstream >

New Header Files included in ANSI C++
Header File Contents and Purpose
< utility > Contains classes and functions that are used
< vector >, < list >, < deque > < queue >, < set >, < map >  < stack >, < bitset > The header files contain classes that implement the standard library containers. Containers store data during a program's execution.
< functional > Contain classes and functions used by algorithms of the standard library.
< memory > Contains classes for manipulating data in the standard library containers.
< algorithm > Contains functions for manipulating data in the standard library containers.
 < exception >, < stdexcept .> These header files contain classes that are used for exception handling
< string > Contains the definition of class string from the standard library. 
< sstream > Contains function prototypes for functions that perform input from strings in memory and output to strings in memory.
< locale > Contains classes and functions normally used by stream processing to process data in the natural form for different languages (e.g, monetary formats, sorting strings, character presentation etc.)
< limits > Contains a class for defining the numerical data type limits on each computer platform.
< typeinfo > Contains classes for run-time identification (determining data types at execution time).

Return type of main()
In C++, main() retuns an integer type value to the operating system. Therefore , every main() in C++ should end with a return (0) statment; oterwise a warning or an erro might occur. Since main () returns an integer type value, return type for main( ) is explicitly specified as int. Note that :he default return type for all functions in C++ is int. The following main without type and return will run with a warning.
Structure of the C++ program
C++ Sections placed in separate code files and then compiled independently or jointly.

The clas declarations are placed in a header file and the definitions of member functions go into another file. This approach enables the programmer to separate the abstract specifications of the interface (class definition) from the implementation details (member functions definition). Finally, the main program that uses the class is placed in a third file which "includes" the previous two files as well as any other files required.
C++ Keywords

A major difference between C and C++ is the limit on the length of a name. While ANSI C recognizes only the first 32 characters in a name, ANSI C++ places no limit on its length and, therefore, all the characters in a name are significant. Basic Data Types
Data types in C++ can be classified under Various categories as shown in : -

Order of Precendence
Order of Precendence in C++ can be classified under Various categories as shown in : -

Compilation Process
Some C++ development environments are very convenient to use. You just enter the code in one window, click on a button or menu to compile, and click on another button or menu to run your code. Error messages show up in a second window, and the program runs in a third window.On other systems you must carry out every step manually.
When you compile your program, the compiler translates the C++ source code (that is, the statements that you wrote) into machine code. The resulting file consists of machine instructions and information on how to load the program into memory prior to execution. Machine code is sometimes called object code, but we do not use that terminology to avoid confusion with C++ objects. Machine code files usually have the extension or obj .c For example, the machine code for hello.cpp the program might be stored in hello.obj .

Manipulators
Manipulators are operators that are used to format the data display. The most commonly used manipilators are endl and setw.The endl manipulator, When used in an output statement, causes a linefeed to be inserted. It has the same effect as using the newline character "\n".
#include < iostsream.h >
#include < iomanip.h >
int main()
{
int basic = 8000, ta=2000, total=10000;
cout << setw(10) << "Basic"<< setw(10) << Basic << endl
<< setw(10) << "ta"<< setw(10) << ta << endl
<< setw(10) << "total"<< setw(10) << total << endl
return 0;
}


Free Web Hosting