Chapter 3 Standard Library types
3.1TheUsingStatement
In general, the header file should only define the necessary things.
# Include <iostream> Using STD: CIN; Using STD: cout; Using STD: Endl; int main () {// some codes .....}
C ++StandardProgramAll identifiers in the library are defined inSTDOfNamespace.
Therefore, it is more convenient to useUsing namespace STD;
For example:
# Include <iostream>
Using namespace STD;
In this way, the namespaceSTDAll identifiers defined in !! You don't have to write them one by one !!
Exercise3.1
//Use appropriateUsingStatement, insteadSTDPrefix: calculates the result of a given power of a given number.
# Include <iostream> Using STD: CIN; Using STD: cout; Using STD: Endl; int main () {int Val, pow, Res = 1; cout <"enter two numbers" <Endl; CIN> Val> POW; For (int cnt = 1; CNT <= POW; CNT ++) res = res * val; cout <"the result of" <Val <"^" <POW <"is" <res <Endl; return 0 ;}