#include <iostream>
using namespace std;

struct Student{
    Student(char *name, int age, float score);
    void show();

    char *m_name;
    int m_age;
    float m_score;
};

Student::Student(char *name, int age, float score): m_name(name), m_age(age), m_score(score){ }
void Student::show(){
    cout<<m_name<<"的年龄是"<<m_age<<",成绩是"<<m_score<<endl;
}

int main(){
    Student stu("小明", 15, 92.5f);
    stu.show();
    Student *pstu = new Student("李华", 16, 96);
    pstu -> show();

    return 0;
}

 

相关文章:

  • 2022-12-23
  • 2021-08-22
  • 2022-01-16
  • 2022-02-20
  • 2021-08-30
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2021-11-18
  • 2021-12-10
  • 2021-08-15
  • 2021-12-31
  • 2021-06-25
相关资源
相似解决方案