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JTZPhRiyUgkQu/ZChM0OyZlIpGI2+1WmsLLt7c8Dnu79FXHrk4sPhac+xMhwE8BChl3CIIUDpQy24eiLJkQNCaTye127/Q6xMPA0CVr/R4AUNVaOP5GYCmHU9RZEwwGaQlJRYkYSr69RVwSLhm1DGh+Xlv/aufQv/NUhbMIUNS4QxCkEKCU2T6UaUmPx2Oz2QDAZrNlUxvoCUAQBI7j9Ho93U5S5k9WprcUI2hJBHniQSmzfSjZkpFIJKFpTCYTx3E+n2+nl2rySTAYdLvdNpuNZVm9Xk9/4E43KhNK9pbiAi2JIE88KGW2j2KxpM/n4zjObDYDgF6vdzgcbrdbafsvGxIKhXw+H8/zZrOZZVmWZW02m9vtVuYaTCrF4i3KBy2JIE88WUkZJF9sQ4/mF0EQaClKk8kEADQ2lud5j8cjCIJylm2CwaAgCDzPOxwOKsJoBAzHcUW6a7bTrvpEsdOdiSBIYcFBjmyCYDBIlzpsNhtd7QAAk8lkNpsdDgfP8zzP+3w+QRDyLnSoWBEEwePx0C8ym82JNlCNxXEcz/OCIBSjdkEQBEG2BkoZJFeoyEhSGAmRQaFSY7NIH6ypYJJqJqpsULUgCII85aCUQbaDSCQibJIcaiwgCIIgTxEoZRAEQRAEKWJQyiAIgiAIUsSglEEQBEEQpIhBKYMgCIIgSBGDUgZBEARBkCIGpQyCIAiCIEUMShkEQRAEQYoYlDIIgiAIghQxKGUQBEEQBCliUMogCIIgCFLEoJRBEARBEKSIQSmDIAiCIEgRg1IGQRAEQZAiBqUMgiAIgiBFDEoZBEEQBEGKGJQyCIIgCIIUMShlEARBEAQpYlDKIAiCIAhSxKCUQRAEQRCkiEEpgyAIgiBIEfP/AcqW5S24YZcUAAAAAElFTkSuQmCC" alt="" width="506" height="82" />
1.1 最小 cpp
int main(){} // minimal cpp
思考一: 为什么最小程序没有 return 语句?
1.2 Hello
#include <iostream> int main()
{
std::cout << "Hello!\n";
}
思考二: \n 和 std::endl 的区别是什么?
1.3 函数
#include <iostream> double Square(double x)
{
return x*x;
} void PrintSquare(double x)
{
std::cout << "The square of " << x << " is "<< Square(x) << '\n';
} int main()
{
PrintSquare(1.21);
}
思考三: Square 有必要写成模板函数么?
2 类型、变量和运算
2.1 定义
声明 (declaration): a statement that introduces a name into the program. It specifies a type for the named entity
类型 (type): (为对象) 定义了一系列可能 值(value) 和一系列 操作(operations)
值 (value): a set of bits interpreted according to a type.
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaMAAAB1CAIAAABs5xklAAAHaElEQVR4nO3dsWrjWBjF8fsKU+oN9hm2UhqV8wgu8gRDCi1bTZlCEJh2QZB+cTXdguqdEPdBsEyzwWUgqBkmaM4WkmMnEyfKdWx9n/b/Y4rBVsyx+O7BkoobBABTF8YOAAB7R9MBmD6aDsD0uWm6YMPYpwFADDdL10LLWMgAIIKbpWuhZSxkABDBzdK10DIWMgCI4GbpWmgZCxkARNhh6d4qTxQy1W38Z7S1sqCs1IufYaFlLGQAEIGmewULGQBE2LnpUhW5QlBIdHbRF1ZTK08VgkJQfq5l/6rmef9immuxlB40Xdtcnh29e19c3jwd1EDLWMgAIMLOTZdofq12qd9ThUTVrdprHSdKjnXdqlkoDTqeq201P+4PVqMi7Q/YaLof379+/vjhU7X89nRQAy1jIQOACLs2XZLrVpJU5QpBeaW67P9zf0zIdHWlLDw+uKy5egVwCG/cdFmpv/KNpmtVZgpBp4WSjabr2jArdUfTAdg/ftO9goUMACK8zX267tZbSLVonrhPl5VP3KfrHtpynw7AAbzBs9d8phAUUs3r/p3l4olnr+1S5zx7BTAGN0vXQstYyAAggpula6FlLGQAEMHN0rXQMhYyAIjgZulaaBkLGQBEcLN0LbSMhQwAIrhZuhZaxkIGABHcLF0LLWMhA4AIbpauhZaxkAFABDdLd1+bfb3S2KcBQAyWLoDpo+kATB9NB2D6aDoA0+em6cZ+FNEb+zQAiOFm6VpoGQsZAERws3QttIyFDAAiuFm6FlrGQgYAEdwsXQstYyEDgAhulq6FlrGQAUCEt166q20Py/rlY1/FQstYyA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haBZobqR1DaXZ0fv3heXN6/6JgdABjKQwWmG596+nisJKhZSq/mxQlBeqb3WcaLkWNetmoXSoOP5g20Pf2667uBlpTQoyXW70XTXcyWJ5tf9x6aFGv34/vXzxw+fquW3V32TAyADGcjgNMP2tx9eY95fvdZlX3nSqtQy1XfPNd2DgxNVN6tPvlOZKcl1K0mq8v6v4r7JAZCBDGRwmmH72/ct9rDpqnyj6e5/yl0Nbrr7gzPVN/0rm//KOvKbHAAZyEAGpxkM/abb8ZscABnIQAanGZ57uyu1F+/TdY9Wu996Za22VhaeuE/XHZwWajY6tC4VUlVLqVGRdkdyn44MZCDDG2cY9uw10enp+tfZcvHTs1dpeaFZonD/pHXz2evJ+q262frsNc21WIpnr2QgAxnePMP4EQdycTbJQAYy2MwwfsSBXJxNMpCBDDYzjB9xIBdnkwxkIIPNDONHHMjF2SQDGchgM8P4EQdycTbJQAYy2MwwfsSBXJxNMpCBDDYzjB9xIBdnkwxkIIPNDONHHCgAwHYvFMhhegoARkTTAZg+mg7A9NF0AKaPpgMwfTQdgOmj6QBMH00HYPr+A1pKZQj27Q6jAAAAAElFTkSuQmCC" alt="" />
2.2 对象和变量
对象 (object): some memory that holds a value of some type
变量 (variable): a named object
2.3 初始化
等号 "=" 属于 C 语言, C++ 中尽量用 {}-list
double d1 = 2.3;
double d2 {2.3}; complex<double> z = ; // a complex number with double-precision floating-point scalars
complex<double> z2 {d1,d2};
complex<double> z3 = {,}; // the = is optional with {...}
vector<int> v {,,,,,}; // a vector of ints
c++11 的 auto
auto b = true; // a bool
auto ch = 'x'; // a char
auto i = ; // an int
auto d = 1.2; // a double
auto z = sqrt(y); // z has the type of whatever sqrt(y) returns
尽量使用 auto,除非如下:
1) in a large scope where we want to make the type clearly visible to readers of our code.
2) be explicit about a variable’s range or precision (e.g., double rather than float ).
3 常量
3.1 const 和 constexpr
const,意思是 “承诺不改变其值”,常用来指定 “接口” (interfaces), 这样 数据 可以传递给 函数 而本身不被修改,编译器通过 const 关键字来保证这种承诺的执行。
const int dmv = ; // dmv is a named constant
int var = ; // var is not a constant
constexpr double max1 = 1.4∗Square(dmv); // OK if square(17) is a constant expression
constexpr double max2 = 1.4∗Square(var); // error : var is not a constant expression
const double max3 = 1.4∗Square(var); // OK, may be evaluated at run time
constexpr :meaning roughly ‘‘to be evaluated at compile time’’. This is used primarily to specify constants, to allow placement of data in memory where it is unlikely to be corrupted, and for performance.
double sum(const vector<double>&); // sum will not modify its argument
vector<double> v {1.2, 3.4, 4.5}; // v is not a constant
const double s1 = sum(v); // OK: evaluated at run time
constexpr double s2 = sum(v); // error : sum(v) not constant expression
3.2 constexpr function
For a function to be usable in a constant expression, that is, in an expression that will be evaluated by the compiler, it must be defined constexpr
constexpr double Square(double x) { return x∗x; }
To be constexpr , a function must be rather simple: just a return -statement computing a value.
A constexpr function can be used for non-constant arguments, but when that is done the result is not a constant expression.
4 控制语句
4.1 if 语句
bool Accept()
{
cout << "Do you want to proceed (y or n)?\n"; // write question char answer = ;
cin >> answer; // read answer if(answer == 'y') return true;
return false;
}
4.2 switch 语句
bool Accept2()
{
cout << "Do you want to proceed (y or n)?\n"; // write question char answer = ;
cin >> answer; // read answer switch(answer) {
case 'y':
return true;
case 'n':
return false;
default:
cout << "I will take that for a no.\n";
return false;
}
}
4.3 while 语句
bool Accept3()
{
int tries = ;
while(tries < ){
cout << "Do you want to proceed (y or n)?\n"; // write question
char answer = ;
cin >> answer; // read answer switch(answer) {
case 'y':
return true;
case 'n':
return false;
default:
cout << "Sorry, I don't understand that.\n";
++tries; // increment
}
}
cout << "I'll take that for a no.\n";
return false;
}
5 指针和数组
5.1 [] 和 *
[ ] 等于 ‘‘array of’’, ∗ 意思是 ‘‘pointer to’’
char v[]; // array of 6 characters
char∗ p; // pointer to character
前缀 ∗ 是取内容, 前缀 & 是取地址
char∗ p = &v[]; // p points to v’s fourth element
char x = ∗p; // *p is the object that p points to
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAToAAABlCAIAAABSj7idA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NL0jfTmmPp9nnMGcvR9wNb+xBHT4hrXFumQoOY6KRCKEkMOHD6+smTOJ2579ZMfRsx/0SKG7svJs+RsXnwk5r8mw+fKhdCp/Ha4Hg58MP1le7jT8ZBjYWTWOOnjwYP7bwq5du/r7+3mnA9QVSlFVtbOzc9u2bYUH+c6dO8+dO4dfAOILdYXSzpw5s3YAu2fPHrzzG0eoK5SgadrarhYes7du3eIdsEGhrlBCNpvt7+/v7u5ua2vbu3cvIWTfvn2Fxm7fvv3kyZN4Gxr2mNZ1vW/YAA2u2gZZ2s/VJ6s6FjIgAzKUONLSHKtPJtSlQQZksFsG1BUZkEGYDKgrMiCDMBlQV2RABmEyoK7IgAzCZEBdkQEZhMlQ7jg1TImD5t+1IadSN6H+KKX6mOTa75LGavh9U7EuDTIgg90ylDtupaLF1V14PBS4KkWTNfxGsFiXBhmQwW4Zyh6Xo2E3dfhpuvAPVrGsgwzIIG6GCsepYUrcVP0/9TuWHrNsYlkHGZBB3AwVjsuvh3sk6ljexLKJZR1kQAZxM1Q6LkfDbkpI0UoYe1dkQAZOGSofp4YpIUUrYUyGkQEZOGXAz12RARmEyYC6IgMyCJMBdUUGZBAmA+qKDMggTAbUFRmQQZgMqCsyIIMwGVBXZEAGYTKwrisArFVtgyztJwDUEeoKIAzUFUAYqCuAMFBXAGGgrgDCQF0BhPEbIJ/v3bUsw+cAAAAASUVORK5CYII=" alt="" />
T a[n]; // T[n]: array of n Ts
T∗ p; // T*: pointer to T
T& r; // T&: reference to T
T f(A); // T(A): function taking an argument of type A returning a result of type T
5.2 拷贝和输出
拷贝一个数组的元素到另一个数组
void CopyFct()
{
int v1[] = {, , , , , , , , , };
int v2[]; for(auto i=; i!=; ++i) // copy elements
v2[i] = v1[i];
}
将 v 中每一个元素的值 , 拷贝给 x 并显示其输出。
void Print()
{
int v[] = {, , , , , , , , , }; for(auto x : v) // range-for 的形式一
std::cout << x << '\n'; // for every element of v, from the first to the last, place a copy in x and print it for(auto x : {, , , , })
std::cout << x << '\n';
}
5.3 引用
void Increment()
{
int v[] = {, , , , , , , , , }; for(auto &x : v) // range-for 的形式二
++x;
}
后缀 & 意思是 ‘‘reference to’’,类似指针,但却不需要一个前缀 ∗ 来访问值
// count the number of occurrences of x in p[]
// p is assumed to point to a zero-ter minated array of char (or to nothing)
int CountX(char* p, char x)
{
if(p==nullptr) return ;
int count = ;
for(; *p!=; ++p)
if(*p == x)
++count;
return count;
}
其中,nullptr 参见博文 C++11 之 nullptr
参考资料:
<C++ Programming Language_4th>
C++笔记 之 基础回顾(一)的更多相关文章
- 数论算法 剩余系相关 学习笔记 (基础回顾,(ex)CRT,(ex)lucas,(ex)BSGS,原根与指标入门,高次剩余,Miller_Rabin+Pollard_Rho)
注:转载本文须标明出处. 原文链接https://www.cnblogs.com/zhouzhendong/p/Number-theory.html 数论算法 剩余系相关 学习笔记 (基础回顾,(ex ...
- C#学习笔记(基础知识回顾)之值类型与引用类型转换(装箱和拆箱)
一:值类型和引用类型的含义参考前一篇文章 C#学习笔记(基础知识回顾)之值类型和引用类型 1.1,C#数据类型分为在栈上分配内存的值类型和在托管堆上分配内存的引用类型.如果int只不过是栈上的一个4字 ...
- C#学习笔记(基础知识回顾)之值传递和引用传递
一:要了解值传递和引用传递,先要知道这两种类型含义,可以参考上一篇 C#学习笔记(基础知识回顾)之值类型和引用类型 二:给方法传递参数分为值传递和引用传递. 2.1在变量通过引用传递给方法时,被调用的 ...
- C#学习笔记(基础知识回顾)之值类型和引用类型
一:C#把数据类型分为值类型和引用类型 1.1:从概念上来看,其区别是值类型直接存储值,而引用类型存储对值的引用. 1.2:这两种类型在内存的不同地方,值类型存储在堆栈中,而引用类型存储在托管对上.存 ...
- 深度学习word2vec笔记之基础篇
作者为falao_beiliu. 作者:杨超链接:http://www.zhihu.com/question/21661274/answer/19331979来源:知乎著作权归作者所有.商业转载请联系 ...
- Quartz学习笔记:基础知识
Quartz学习笔记:基础知识 引入Quartz 关于任务调度 关于任务调度,Java.util.Timer是最简单的一种实现任务调度的方法,简单的使用如下: import java.util.Tim ...
- [C#] C# 基础回顾 - 匿名方法
C# 基础回顾 - 匿名方法 目录 简介 匿名方法的参数使用范围 委托示例 简介 在 C# 2.0 之前的版本中,我们创建委托的唯一形式 -- 命名方法. 而 C# 2.0 -- 引进了匿名方法,在 ...
- Javascript基础回顾 之(三) 面向对象
本来是要继续由浅入深表达式系列最后一篇的,但是最近团队突然就忙起来了,从来没有过的忙!不过喜欢表达式的朋友请放心,已经在写了:) 在工作当中发现大家对Javascript的一些基本原理普遍存在这里或者 ...
- Javascript基础回顾 之(二) 作用域
本来是要继续由浅入深表达式系列最后一篇的,但是最近团队突然就忙起来了,从来没有过的忙!不过喜欢表达式的朋友请放心,已经在写了:) 在工作当中发现大家对Javascript的一些基本原理普遍存在这里或者 ...
随机推荐
- IE浏览器打开chorme浏览器,如何打开其他浏览器
看到这个标题是否感觉奇怪,为什么要用IE浏览器打开chorme或者火狐浏览器等,这个功能从开发者来说不是一个好的需求,但确实是真实存在的,有用公司的背景历史比较复杂,而且公司有过长期的开发历史,这导致 ...
- iOS --------Crash 分析(一)
iOS Crash 分析(文一)- 开始 1. 名词解释 1. UUID 一个字符串,在iOS上每个可执行文件或库文件都包含至少一个UUID.目的是为了唯一识别这个文件. 2. dwarfdump 苹 ...
- NotSupportedException-无法将类型“System.DateTime”强制转换为类型“System.Object”
几张图就可以说明一切 2015-03-29 21:54:09,206 [77] ERROR log - System.NotSupportedException: 无法将类型“System.DateT ...
- VS2013常用快捷键你敢不会?
F1 帮助文档 F5 运行 F12 跳转到定义 F11 单步调试 Shift+F5 停止调试 Ctrl+滚轮 放大缩小当前视图 Ctrl+L 删除当前行 Ctrl+K,Ctrl+C 注释选中代码 Ct ...
- WPF根据Oracle数据库的表,生成CS文件小工具
开发小工具的原因: 1.我们公司的开发是客户端用C#,服务端用Java,前后台在通讯交互的时候,会用到Oracle数据库的字段,因为服务器端有公司总经理开发的一个根据Oracle数据库的表生成的cla ...
- nodejs 批量修改、删除
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAAQhCAIAAABDaAVHAAAgAElEQVR4nOydeXxU5aH359733vd9b/ ...
- JavaScript 开发技巧 || 返回有效值
<script type="text/javascript">var objOne = undefined || "" || null || 1 | ...
- 爆一个VS2015 Update1更新带来的编译BUG【已有解决方案】
一个编译的BUG,在原生的VS2015中没有问题,但更新至VS2015 Update1之后就有了,大概是Update1用了新的编译器,害得我好苦.经测试,VS2013 Update5中也存在这个问题, ...
- iOS开发之窥探UICollectionViewController(二) --详解CollectionView各种回调
UICollectionView的布局是可以自己定义的,在这篇博客中先在上篇博客的基础上进行扩充,我们先使用UICollectionViewFlowLayout,然后好好的介绍一下UICollecti ...
- Visual Studio 2015 开发 ASP.NET 5 有何变化?
本篇博文目录: ASP.NET 5 模版 ASP.NET 5 目录结构 前端管理工具 无编译开发 Microsoft Git Provider 智能感知和错误信息 Smart Unit Testing ...