C++ Primer 点点滴滴 Chater1
来源:互联网 发布:数据质量分析工具 编辑:程序博客网 时间:2024/06/16 04:21
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.
- C++ Primer 点点滴滴 Chater1
- 点点滴滴C
- DataTable的点点滴滴(C#)
- c语言中的点点滴滴
- C语言点点滴滴
- c语言的点点滴滴
- Python的点点滴滴(C extending)
- 悉数学习c的点点滴滴
- C++primer
- 《C++primer》
- C++primer
- C++primer
- C++Primer
- 点点滴滴
- 点点滴滴
- 点点滴滴
- 点点滴滴
- 点点滴滴
- java flash tcp字节流通信(二)-java 服务端
- video4linux(v4l)使用摄像头的实例基础教程与体会
- 理解JavaScript的caller,callee,call,apply
- [置顶] Image Tips for Windows Phone 7
- java flash tcp字节流通信(二)-flash as3客户端
- C++ Primer 点点滴滴 Chater1
- JavaScript修改样式(style)
- Java,指定文字列,可以按照指定的文字数多行显示
- mysql中创建视图作用已经如何创建视图
- Sencha Touch 2 快速入门系列(三)-- 组件之表格(Forms)
- java中对日期的加减操作
- 判断某棵二叉树是否二叉排序树
- android Binder工作流程
- thrift java多线程非阻塞同步/异步调用实例