Before proceed to further, let us go through some basic requirements which we have to use in our programs.
Some main concepts we have to concentrate are
1. Header Files
2. Screen I/O in C++.
Header Files
•Header files are used for declarations
•Header files can be included for using their corresponding .cpp files
•Header files can be included in a nested structure
•Standard C header files have been renamed and placed in namespaces
–e.g. <cstdlib>, <cctype>,<cstdio>
How this header file works?
Have a look at this.
Header files are linked to supported library automatically when its called during runtime.
A library includes
1. A header file that contains declarations for everything the library wishes to expose to users.
2. A pre-compiled object that contains all of the implementation code compiled into machine language.
Now a question may arise.
Why are libraries precompiled?
The reasons are
1. Since libraries rarely change, they do not need to be recompiled. It would be a waste of time to compile them every time you wrote a program that used them.
2. Since precompiled objects are in machine language, it prevents people from accessing or changing the source code.
Note: You can write your own header files and save it in a library so that you can able to access that in your program.
Hope this is sufficient regarding header files.
2. Screen I/O in C++.
Have a look at the above figure,
•It is perfectly valid to use the same I/O statements in C++ as in C .
The very same printf, scanf, and other stdio.h functions that have been used in C.
•However, C++ provides an alternative with the new stream input/output features. The header file is named iostream and the stream I/O capabilities are accessible when you use the pre-processor declaration:
#include <iostream> // No “.h” on std headers
using namespace std; // To avoid things like
// std::cout and std::cin
•Several new I/O objects available when you include the iostream header file. Two important ones are:
–cin // Used for keyboard input (std::cin)
–cout // Used for screen output (std::cout)
•Since cin and cout are C++ objects, they are somewhat "intelligent":
–They do not require the usual format strings and conversion specifications.
–They do automatically know what data types are involved.
–They do not need the address operator, &.
–They do require the use of the stream extraction ( >> ) and insertion ( << ) operators.
•Both cin and cout can be combined with other member functions for a wide variety of special I/O capabilities in program applications.
•cout
•cin
•Operator <<
•Operator >>
Hope this is sufficient to proceed further to implement bit complex codes.


No comments:
Post a Comment