#include <iostream>
#include <string>
using namespace std;
class Activity {
public:
string name;
string date;
Activity(string n="", string d = "") : name(n), date(d) {}
};
class ActivityManager {
private:
static const int MAX = 10; // 设置最大活动数
Activity activities[MAX];
int num;
public:
ActivityManager():num(0){}
void addActivity(const Activity& activity) {
if (num < MAX) {
activities[num++] = activity;
cout << "活动增加: " << activity.name << endl;
}
else {
cout << "活动已经超过最大数量!" << endl;
}
}
void displayActivities() {
if (num == 0) {
cout << "活动为空" << endl;
}
else {
cout << "活动:" << endl;
for (int i = 0; i < num; ++i) {
cout << "活动名: " << activities[i].name << ", 活动日期: " << activities[i].date << endl;
}
}
}
};
int main() {
ActivityManager manager;
// 添加活动
Activity activity1("活动一", "2023-01-01");
manager.addActivity(activity1);
Activity activity2("活动二", "2023-02-15");
manager.addActivity(activity2);
// 显示所有活动
manager.displayActivities();
return 0;
}