学习Accelerated C++1

第0章
0-2题目
输出指定的话
编程如下
#include
using namespace std;

int main()
{
cout << “This (”)is a quote,and this (\)is abacklash" << endl;
system (“pause”);
return 0;
}

值得注意的是括号里面的“和\的输出
都应用“和\,前面加\,原因在6页上,\“是吧这个符号当做字符串的一部分而不是把它当做字符串的结束,\若字符串中包括一个\,那么就可以吧接下来的字符当做普通字符来处理。

0-4题目
我编写的程序
#include
using namespace std;

int main()
{
cout << “Hello,world!” <<endl;
cout << “This (”)is a quote,and this (\)is a backlash" << endl;
cout << “a small C++ program”<< endl;
cout << “#include " << endl;
cout << “using namespace std;” << endl;
cout << “int main()” << endl;
cout << “{” << endl;
cout << " cout << “Hello, world!” <<endl;” << endl;
cout << " return 0;" << endl;
cout << “}” << endl;
system (“pause”);
return 0;
}
而网上下载下来的程序比自己的简单很多
运用了\n换行符和\t水平制表符
\t水平制表就是调到下个Tab位置 就相当于自己空格

第一章
很多会忘记的小知识点和概念
1.重载
3+4和字符串之间的+的意义不同
运算符对于不同类型的操作数来说具有不同的含义
2.常量 const
在定义常量的时候要赋初值,要不然后面么机会赋值了

string name;
const string m=name;
这样并不代表name也是常量
3.<< +是左结合的
cout<<s<<t相当于(cout<<s)<<t
4.字符直接量 字符串直接量
字符直接量用‘’来括起来 字符串直接量用“”括起来
哪里会用到字符直接量呢
比如
string name=doris;
string first(name.size(),‘ ’);//这里用到了字符直接量
5.给字符定义的方式
string name=”doris“;
string name(first.size()。‘ ’;
string name;.
.
课后题都蛮简单的,上机运行一下就可以

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值