1.the iostream libary already define 4 IO Objects,please note objects, that mean we can use these objects derectly without allocate and init it.
cin,cout,cerr,clog.
2.:about std::cout<< "enter tow number"<<std::endl; statment.
in C++ every expression produces a result,which typciallly is the value generated by applying an operator to its operands. in the case of the output operator,the result
is the value of its left-hand operand. so std:cout<<"enter tow number" return std:cout,then we use the this operand to the second ouptput operator as a left-hand operand.
so it equivalent to :
std::count<<"enter tow number";
std::count<<std::endl;
that's the same as cin object like std::cin::<<var1<<var2;
3.when writing a c++ programe,in most places that a space appears we could instead use a new line. one exception to this rule is that spaces inside a string literal can not
be replace by a new line. Another exception is that spaces are not allowed inside preprocessor directives.
4.when defeine a variable,we should give it an initial value unless we are certain that the initial value will be overwritten before the variable is used for any other purpose.
if we can't guarantee that the variable will be reset before being read,we should initrialize it.
5.nonzero value can be tested as true, while zero value of a expression can be tested as false
6. for (int val=1;val<10;val++) //this is the " for header"
{
......................... / here is the "for bodoy"
} in the new standar C++ the val variable no longer be accessible while we exit the for loop.
however in the pre-stander C++ names define in the for header can still be accessible when exit the for loop statement.
7.Reading an Unknow numbers of input.
int sum=0,val=0;
while(std::cin>>val)
{
sum+=val;
}
As >> input operate return its left-hand operand,so the while statement test std::cin. when we use an istream as a condition,the effect is to test the state of the stream.
if the sream is validate-that's still possible to read another input,then the test successds.
an istream become invalidat when we hit end-of-file (Winwos ctr+z, unix/Mac ctr+d) or encounter an invalid input ,such as reading a value that's not an integer,then will case the condition to faild.