当前位置:网站首页>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;
}
边栏推荐
- POJ 2208 已知边四面体六个长度,计算体积
- Heavy! Ant open source trusted privacy computing framework "argot", flexible assembly of mainstream technologies, developer friendly layered design
- 30 minutes to understand PCA principal component analysis
- QT中Model-View-Delegate委托代理机制用法介绍
- Interview shock 62: what are the precautions for group by?
- 从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
- Dichotomy (integer dichotomy, real dichotomy)
- 2022暑期项目实训(二)
- Codeforces Round #803 (Div. 2)
- 2019阿里集群数据集使用总结
猜你喜欢
QT中Model-View-Delegate委托代理机制用法介绍
[swoole series 2.1] run the swoole first
FMT open source self driving instrument | FMT middleware: a high real-time distributed log module Mlog
1700C - Helping the Nature
Declval of template in generic programming
MS-TCT:Inria&SBU提出用于动作检测的多尺度时间Transformer,效果SOTA!已开源!(CVPR2022)...
Olivetin can safely run shell commands on Web pages (Part 1)
Declval (example of return value of guidance function)
1700C - Helping the Nature
Introduction and case analysis of Prophet model
随机推荐
Ms-tct: INRIA & SBU proposed a multi-scale time transformer for motion detection. The effect is SOTA! Open source! (CVPR2022)...
TCP packet sticking problem
Interview shock 62: what are the precautions for group by?
Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
Brief description of SQL optimization problems
Principle and usage of extern
【LeetCode第 300 场周赛】
Wchars, coding, standards and portability - wchars, encodings, standards and portability
小程序在产业互联网中的作用
CSRF漏洞分析
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
2022暑期项目实训(三)
文档编辑之markdown语法(typora)
Will openeuler last long
2022暑期项目实训(一)
Transfer data to event object in wechat applet
TOP命令详解
2022 Summer Project Training (II)
Take you through ancient Rome, the meta universe bus is coming # Invisible Cities
Fleet tutorial 13 basic introduction to listview's most commonly used scroll controls (tutorial includes source code)