Accelerated C++ day1
来源:互联网 发布:网络舆情分析系统 编辑:程序博客网 时间:2024/03/29 01:43
这本书提醒多次,是c++不是c。核心在于高级抽象。
0.一些概念//Pre
a.表达式与运算符
类型的表示的是一种数据结构以及对此数据结构的合理操作。运算符的操作取决于它的操作数类型。
内建类型:int...,拓展:std::ostream
(std::cout<<"This is a project:became a cpp master less than one month")<<std::endl //——std::endl 是个manipulator,控制cout)
b作用域(::作用域运算符)
名称空间:在名称空间中定义了所有名称
花括号:
#include <iostream>
int main(){
std::cout << "This is a project:became a cpp master less than one month" << std::endl;
getchar();
return 0;
}
1.string
a.input
string 类型 用string name来声明一个string 变量
(变量是具有名称的对象,对象是在计算机中具有类型的内存空间)
#include <iostream>
#include <string>
using namespace std;
int main(){
cout << "This is a project:became a cpp master less than one month" << endl;
cout << "type in your name:\n";
string name;
cin >> name;
cout << "nice to meet you! Mr." << name<<"!";
getchar();
getchar();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(){
cout << "This is a project:became a cpp master less than one month" << endl;
cout << "type in your name:\n";
string name;
cin >> name;
const string greeting = " hello," + name + "! ";
const string spaces(greeting.size(),' ');
const string secondline = "*" + spaces + "*";
const string firstline(secondline.size(), '*');
//cout << "nice to meet you! Mr." << name<<"!";
cout << firstline << endl;
cout << secondline << endl;
cout << '*'<<greeting<<'*' << endl;
cout << secondline << endl;
cout << firstline << endl;
getchar();
getchar();
return 0;
}
- Accelerated C++ day1
- 读《Accelerated C++》有感
- 【Accelerated C++】读书笔记(一)
- 【Accelerated C++】读书笔记(二)
- 【Accelerated C++】读书笔记(三)
- 【Accelerated C++】读书笔记(四)
- 【Accelerated C++】读书笔记(五)
- 【Accelerated C++】读书笔记(六)
- 【Accelerated C++】重点回顾
- 《Accelerated C++》 笔记摘录
- 《accelerated c++》---------第六章
- Accelerated C++Exercises' Resolutions
- 【Accelerated C++】重点回顾
- Accelerated C++<3-2>
- Accelerated C++<4-1>
- Accelerated C++<4-2>
- Accelerated C++<4-3>
- Accelerated C++<4-4>
- java 实现下载htttp文件的简便办法 FileUtils IOUtils
- 免费台球计费软件,免费台球计费系统
- NSTableView and NSTextFiled
- Collection <__NSArrayM: 0xxxxxxx> was mutated while being enumerated.
- 静态库 .a 和 framework
- Accelerated C++ day1
- Android中如何设置RadioButton在文字的右边,图标在左边
- Linux网络编程中EAGAIN错误和EINTR错误
- 用js实现鼠标移动文字上变色
- XtraBackup,在使用innobackupex 中出现了错误: perl-DBD-MySQL 无法安装
- 将时间转换成yyyy-MM-dd HH:mm:ss的格式字符串
- 设计编码中常见Bug及应对方法
- WCF 通过web.config配置文件解决传输内容过大问题
- SQL optimization:Implicit Conversion will cause index scan instead of index seek.