class C {
public:
char getClass();
int getN();
};
class A :public C {
public:
A(int n) {
this->n = n;
}
char getClass() {
return 'A';
}
int getN() {
return n;
}
private:
int n;
};
class B :public C {
public:
B(int n) {
this->n = n;
}
char getClass() {
return 'B';
}
int getN() {
return n;
}
private:
int n;
};
C *a[100];
void PrintInfo(C* a) {
cout << a->getClass() << " " << a->getN();
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
char c;
int k;
cin >> c >> k;
if (c == 'A')
a[i] = new A(k);
else
a[i] = new B(k);
}
cout << n << endl;
for (int i = 0; i < n; ++i)
PrintInfo(a[i]);
cout << "****" << endl;
}
}
A,B继承C类,main函数不能动,这个PrintInfo函数有什么问题吗,要怎么解决