当前位置:网站首页>Copy constructor template and copy assignment operator template
Copy constructor template and copy assignment operator template
2022-07-06 10:38:00 【pickled cabbage】
#include <iostream>
#include <string>
using namespace std;
template <typename T1>
class A
{
public:
// Constructor template
template <typename T2>
A(T2 v1, T2 v2);
// Member function template
template <typename T3>
void myft(T3 tmpt)
{
cout << tmpt << endl;
}
T1 m_ic;
static constexpr int m_stcvalue = 200;
public:
A(double v1, double v2)
{
cout << "A(double v1, double v2)" << endl;
}
A(T1 v1, T1 v2)
{
cout << "A(T1 v1, T1 v2)" << endl;
}
public:
// Copy constructor template
template <typename U>
A(const A<U>& other)
//A(A<U>& other)
{
cout << "A::A(const A<U>& other)" << endl;
}
// Copy assignment operator template
template <typename U>
A<T1>& operator=(const A<U>& other)
//A<T1>& operator=(A<U>& other)
{
cout << "operator=(const A<U>& other)" << endl;
return *this;
}
};
// Off class definition
template <typename T1>
template <typename T2>
A<T1>::A(T2 v1, T2 v2)
{
cout << "A::A(T2,T2) Yes !" << endl;
}
int main()
{
A<float> a(11.1f, 12.2f);
a.m_ic = 16.2f;
A<float> a1(a);
return 0;
}
// If the parameters of copy constructor template and copy assignment operator template are not const, Will not call .
If you bring it const, And make corresponding calls , So here a1 The type of needs to be similar to a Different types of , For example int.
边栏推荐
- 使用OVF Tool工具从Esxi 6.7中导出虚拟机
- Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved
- Global and Chinese market for intravenous catheter sets and accessories 2022-2028: Research Report on technology, participants, trends, market size and share
- Technology | diverse substrate formats
- Mysql30 transaction Basics
- 实现微信公众号H5消息推送的超级详细步骤
- Not registered via @EnableConfigurationProperties, marked(@ConfigurationProperties的使用)
- 15 medical registration system_ [appointment registration]
- 软件测试工程师必备之软技能:结构化思维
- Use of dataset of pytorch
猜你喜欢

MySQL23-存儲引擎
![[after reading the series of must know] one of how to realize app automation without programming (preparation)](/img/eb/e789d88f10787c302f9457ca7ca2cc.jpg)
[after reading the series of must know] one of how to realize app automation without programming (preparation)

API learning of OpenGL (2002) smooth flat of glsl

Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved

Jar runs with error no main manifest attribute

MySQL20-MySQL的数据目录

Nanny hand-in-hand teaches you to write Gobang in C language

保姆级手把手教你用C语言写三子棋

MySQL32-锁

Mysql27 - Optimisation des index et des requêtes
随机推荐
Global and Chinese market of transfer switches 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL25-索引的创建与设计原则
好博客好资料记录链接
Introduction tutorial of typescript (dark horse programmer of station B)
Record the first JDBC
[after reading the series of must know] one of how to realize app automation without programming (preparation)
使用OVF Tool工具从Esxi 6.7中导出虚拟机
MySQL combat optimization expert 05 production experience: how to plan the database machine configuration in the real production environment?
MNIST implementation using pytoch in jupyter notebook
[paper reading notes] - cryptographic analysis of short RSA secret exponents
第一篇博客
MySQL实战优化高手06 生产经验:互联网公司的生产环境数据库是如何进行性能测试的?
Windchill配置远程Oracle数据库连接
[unity] simulate jelly effect (with collision) -- tutorial on using jellysprites plug-in
Just remember Balabala
MySQL combat optimization expert 03 uses a data update process to preliminarily understand the architecture design of InnoDB storage engine
Security design verification of API interface: ticket, signature, timestamp
如何搭建接口自动化测试框架?
ByteTrack: Multi-Object Tracking by Associating Every Detection Box 论文阅读笔记()
Mysql27 index optimization and query optimization