在 c++ 中与大型代码库作斗争
Struggling with large code base in c++
我知道一些基本概念,如复制构造函数和其他 c++ 概念,如下例所示
#include<iostream>
#include<stdio.h>
using namespace std;
class Test
{
public:
Test() {}
Test(const Test &t)
{
cout<<"Copy constructor called "<<endl;
}
Test& operator = (const Test &t)
{
cout<<"Assignment operator called "<<endl;
}
};
int main()
{
Test t1, t2;
t2 = t1;
Test t3 = t1;
getchar();
r
eturn 0;
}
现在,当我试图在办公室中理解项目的代码流时,但我正在为此苦苦挣扎。我无法弄清楚流程如何进行。有时我得到了一些概述,但是当我深入研究代码时,我没有将c ++概念连接到实际代码。
代码流如下所示:
-
Test t1, t2
t1、t2 将被构造,但没有提供参数,因此调用默认构造函数,不输出任何内容。 - 调用运算符 =
t2 = t1
,输出Assignment operator called
-
t3 = t1
t3 将被构造,并且 t1 作为参数提供,因此调用复制构造函数,输出Copy constructor called
另外,将stdio.h
更改为 cstdio
,C++使用 cstdio
而不是 stdio.h
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 为什么在这个代码结束循环中没有得到结束
- 在c代码之间共享数据的最佳方式
- 在 c++ 中与大型代码库作斗争