#include<iostream>
using namespace std;
//重载函数
class PrintData
{
public:
void print(int i) {
cout << "整数为:" << i << endl;
}
void print(double f) {
cout << "浮点数为:" << f << endl;
}
void print(char c[]) {
cout << "字符串为:" << c << endl;
}
};
int main()
{
PrintData pd;
pd.print(5);
pd.print(233.44);
char c[] = "hello c++";
pd.print(c);
return 0;
}
c++——重载函数
最新推荐文章于 2023-06-22 09:31:03 发布