编程语言语法回顾.pptVIP

  • 5
  • 0
  • 约7.81千字
  • 约 48页
  • 2017-10-03 发布于浙江
  • 举报
* //派生类--Student class Student: public People{ private: float score; public: void setScore(float); float getScore(); }; void Student::setScore(float score){ this-score = score; } float Student::getScore(){ return score; } int main(){ Student stu; stu.setName(小明); stu.setAge(16); stu.setScore(95.5f); coutstu.getName()的年龄是 stu.getAge(),成绩是 stu.getScore()endl; return 0; } * 继承权限: 1) public继承方式 ? 基类中所有public成员在派生类中为public属性; ? 基类中所有protected成员在派生类中为protected属性; ? 基类中所有private成员在派生类中不可访问。 2) protected继承方式 ? 基类中的所有public成员在派生类中为protected属性; ? 基类中的所有protected成员在

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档