explicit 防止隐式类型转换
#define _CRT_SECURE_ND_WARNINGS
#include<iostream>
#include<string>
using namespace std;
class MyString
{
public:
MyString(const char* str)
{
}
explicit MyString(int a)
{
mSize = a;
}
char* mStr;
int mSize;
};
void text01()
{
MyString str = "abc";
MyString str2(10);
//MyString str3 = 10;//str2字符串为“10” 字符串长度为10
//隐式类型转换 Mystring str3 =Mystring (10);
//explicit 防止隐式类型转换
}
int main()
{
system("pause");
return EXIT_SUCCESS;
}