class Student < Person
来源:互联网 发布:暴风影音mac版使用说明 编辑:程序博客网 时间:2024/06/07 20:49
# encoding: utf-8#E4.4-1.rb ,接着上一节的代码,添加如下:class Persondef initialize( name, age=18 )@name = name@age = age@motherland = "China"end #初始化方法结束def talkputs "my name is "+@name+", age is "+@age.to_sif @motherland == "China"puts "I am a Chinese."elseputs "I am a foreigner."endend # talk方法结束attr_writer :motherlandend # Person类结束class Student < Persondef talkputs "I am a student. my name is "+@name+", age is "+@age.to_send # talk方法结束end # Student类结束p3=Student.new("kaichuan",25); p3.talkp4=Student.new("Ben"); p4.talk=beginI am a student. my name is kaichuan, age is 25I am a student. my name is Ben, age is 18请按任意键继续. . .=end
- class Student < Person
- JAVA-继承、覆盖class Student extends Person { }
- student.class
- Person Student Employee Faculty Staff 类
- 创建子类student继承父类person
- 创建继承类Person的类Student
- 创建继承类Person的类Student
- C# public class Person
- [笔记]Student-Class
- Problem A: Person类与Student类的关系
- Problem A: Person类与Student类的关系
- Problem B: Person类与Student类的关系
- 创建继承于类person的类student
- 创建继承于类person的类student
- 创建继承于类person的类student
- public class Student implements Serializable{
- class Person attr_writer :motherland attr_writer :age
- [C++学生类] The Student Class
- JAVA内存原型
- windows2008 IIS7设置伪静态
- 学习笔记:GDI,截图功能实现
- C++ 批量修改 一个目录下面 的文件名
- Direct2D教程(一)
- class Student < Person
- JRE、 JDK和SDK分别是什么
- 架构设计和包图
- 大三上学期10月份几乎被荒废
- 增强父类的方法(用关键字super指明)
- 补码 原码 反码
- UVA 11549 Calculator Conundrum
- 数据结构之线段树
- iFrame 做导航