```c++
#include
using namespace std;
class Sample
{
public:
int v;
/******补充你的代码******/
/************************/
};
void PrintAndDouble(Sample o)
{
cout << o.v;
cout << endl;
}
int main()
{
Sample a(5);
Sample b = a;
PrintAndDouble(b);
Sample c = 20;
PrintAndDouble(c);
Sample d;
d = a;
cout << d.v;
return 0;
}
要求最后运行结果为
9
22
5
```
// 添加构造函数
Sample() {}
Sample(int num) : v(num) {}
// 添加运算符重载函数
Sample operator=(const Sample& other) {
this->v = other.v;
return *this;
}
// 添加类型转换构造函数
operator int() {
return v;
}
F5
启动调试,经常用来直接跳到下一个断点处。
F9
创建断点和取消断点
断点的重要作用,可以在程序的任意位置设置断点。
这样就可以使得程序在想要的位置随意停止执行,继而一步步执行下去。
F5一般与F9一并使用,在下列例子中会提到具体使用方法
F10
逐过程,通常用来处理一个过程,一个过程可以是一次函数调用,或者是一条语句。
跳过自定义函数
F11
逐语句,就是每次都执行一条语句,但是这个快捷键可以使我们的执行逻辑进入函数内部(这是 最长用的)。
不跳过自定义函数
CTRL + F5
开始执行不调试,如果你想让程序直接运行起来而不调试就可以直接使用。