#include <iostream>
using namespace std;
class Student
{
public:
Student(char* pName)
{
cout << "call one parameter constructor" << endl;
strncpy_s(name, pName, sizeof(name));
name[sizeof(name) - 1] = '\0';
cout << "the name is" << name << endl;
}
Student(){ cout << "call no parameter constructor" << endl; }
void display()
{
cout << "the name of the student is" << name << endl;
}
protected:
char name[20];
};
int main()
{
static Student noName1;
Student noName2;
Student ss("Jenny");
noName1.display();
noName2.display();
return 0;
}

没有重载函数可以转换所有参数类型
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 萌子增肥QAQ 2023-03-16 13:51关注
http://t.csdn.cn/OLSvm
解决方法在这本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报