#include<iostream>
using namespace std;
class Student
{
public:
Student(int,int);
void display();
private:
int number;
int score;
};
Student::Student(int a,int b)
{
number=a;
score=b;
}
void Student::display()
{cout<<number<<":"<<score<<endl;}
int main()
{
Student* p;
p= new Student[5]; //为什么总是提示没有合适的构造函数,这里我是想动态建立一个包含5个对象对象数组,并用指针指向首对象,并不是想调用构造函数
Student student[5]={Student(1,89),Student(2,92),Student(3,98),Student(4,95),Student(5,81)};
int i;
for(i=0;i<5;i=i+2)
{
p[i].display();
}
cout<<endl;
delete p;
return 0;
}
长风秋雁
元芳怎么了
桃花长相依