#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
class Swap {
private:
int a, b;
public:
Swap(int n,int m):a(n),b(m){}
Swap(double c)
{
cout << "swap constructor is calling" << endl;
a = static_cast<int>(c);
b = 0;
}
void show()
{
cout << a << ' ' << b << endl;
}
};
int main()
{
Swap s1(1,2);
Swap s2(3.2);
s1.show();
s2.show();
system("pause");
return 0;
}
转换构造函数
猜你喜欢
转载自blog.csdn.net/weixin_43838785/article/details/92108901
今日推荐
周排行