#include<iostream>
#include<string>
using namespace std;
class Student{
public:
Student(int age){
this->age = age;
cout<<this->age<<endl;
}
private:
int age;
};
class Teacher{
public:
explicit Teacher(int age){
this->age = age;
cout<<this->age<<endl;
}
private:
int age;
};
int main(){
Student zhang(23);
Student wang = 43;
Teacher xue = Teacher(50);
// Teacher zhao = 50;
return 0;
}
explicit关键字的使用
最新推荐文章于 2025-06-04 19:42:46 发布
