使用下列程序,在写出两名学生

#include
using namespace std;
class Student
{
private:
char *m_name;
int m_age;
float m_score;
public:
void setname(char *name);
void setage(int age);
void setscore(float score);
void show();
};
void Student::setname(char *name)
{
m_name = name;
}
void Student::setage(int age)
{
m_age = age;
}
void Student::setscore(float score)
{
m_score = score;
}
void Student::show()
{
cout<<m_name<<"的年龄是"<<m_age<<",成绩是"<<m_score<<endl;
}
int main()
{
Student stu;
stu.setname("小明");
stu.setage(15);
stu.setscore(92.5f);
stu.show();
Student *pstu = new Student;
pstu->setname("李华");
pstu->setage(16);
pstu->setscore(96);
pstu->show();
return 0;
}

在main函数中添加两个实例就是了啊。

#include <iostream>
using namespace std;
class Student
{
private:
    char *m_name;
    int m_age;
    float m_score;
public:
    void setname(char *name);
    void setage(int age);
    void setscore(float score);
    void show();
};
void Student::setname(char *name)
{
    m_name = name;
}
void Student::setage(int age)
{
    m_age = age;
}
void Student::setscore(float score)
{
    m_score = score;
}
void Student::show()
{
    cout<<m_name<<"的年龄是"<<m_age<<",成绩是"<<m_score<<endl;
}
int main()
{
    Student stu;
    stu.setname("小明");
    stu.setage(15);
    stu.setscore(92.5f);
    stu.show();
    Student *pstu = new Student;
    pstu->setname("李华");
    pstu->setage(16);
    pstu->setscore(96);
    pstu->show();

    //添加如下
    Student stu3;
    stu3.setname("张三");
    stu3.setage(22);
    stu3.setscore(88);
    stu3.show();

    Student *stu4 = new Student;
    stu4->setname("李四");
    stu4->setage(33);
    stu4->setscore(78.5f);
    stu4->show();


    return 0;
}