当前位置:网站首页>2022/02/12
2022/02/12
2022-07-06 18:19:00 【ekkoxxxx】
Constructors : Because the data members of a class cannot be initialized when the class is declared , So the constructor is introduced to initialize . Grammatical features : no return value .
public:
Test()
{
}
Destructor : Contrary to constructors , When out of scope , Automatic execution of destructors , For example, free the memory in the heap . Constructors can have multiple , There is only one destructor , Grammatical features : Again, there is no return value .
~Test()
{
}
overloaded function : When writing code, you often encounter some functions with the same function but different details , For example, the function of adding two numbers Add, But it is not clear that the two numbers are int,double,float What kind of , Therefore, overloaded functions are introduced to facilitate code writing .
#include<iostream>
#include<Windows.h>
using namespace std;
int Add(int a, int b)
{
return a + b;
}
double Add(double a, double b)
{
return a + b;
}
float Add(float a, float b)
{
return a + b;
}
int main()
{
cout<<Add(1,2)<<endl;
cout<<Add(3.4, 5.6)<<endl;
cout << Add(2.34, 3.45) << endl;
system("pause");
return 0;
}
边栏推荐
- 2022暑期项目实训(一)
- 关于这次通信故障,我想多说几句…
- 容器里用systemctl运行服务报错:Failed to get D-Bus connection: Operation not permitted(解决方法)
- STM32+ESP8266+MQTT协议连接OneNet物联网平台
- win10系统下插入U盘有声音提示却不显示盘符
- Splay
- 随着MapReduce job实现去加重,多种输出文件夹
- FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
- C language exchanges two numbers through pointers
- IP, subnet mask, gateway, default gateway
猜你喜欢
SAP Fiori 应用索引大全工具和 SAP Fiori Tools 的使用介绍
从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
I want to say more about this communication failure
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
STM32 key state machine 2 - state simplification and long press function addition
Declval of template in generic programming
【.NET CORE】 请求长度过长报错解决方案
On time and parameter selection of asemi rectifier bridge db207
Implementation of queue
随机推荐
C language college laboratory reservation registration system
模板于泛型编程之declval
测试123
bonecp使用数据源
Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
阿里云国际版ECS云服务器无法登录宝塔面板控制台
Splay
Distill knowledge from the interaction model! China University of science and Technology & meituan proposed virt, which combines the efficiency of the two tower model and the performance of the intera
win10系统下插入U盘有声音提示却不显示盘符
使用block实现两个页面之间的传统价值观
J'aimerais dire quelques mots de plus sur ce problème de communication...
STM32按键状态机2——状态简化与增加长按功能
declval(指导函数返回值范例)
2022暑期项目实训(二)
【.NET CORE】 请求长度过长报错解决方案
epoll()无论涉及wait队列分析
Codeforces Round #803 (Div. 2)
30 分钟看懂 PCA 主成分分析
TOP命令详解
Recommend easy-to-use backstage management scaffolding, everyone open source