<span style="font-size:18px;">//成员函数指针
#include <iostream>
using namespace std;
//全局函数
void test (){
cout << "this is test" << endl;
}
void test2 (int a){
cout << "this is test22222" << endl;
}
//结构体
struct Date{
int year;
int month;
int day;
//成员函数
void show(){
cout << year << ' ' << month << ' ' << day << endl;
}
//有参
void show2(int a,int b){
cout << "这是有参的成员函数" << endl;
cout << year << '-' << month << '-' << day << ' ' << a+b << endl;
}
//无参
void showYear(){
cout << "今年是 " << year << " 年!" << endl;
}
int add(){
return year + month + day;
}
int sub(){
retu
C++成员函数指针与其应用场景
最新推荐文章于 2024-03-20 19:23:33 发布