def StudentClass.student_count

来源:互联网 发布:修改pdf文件的软件 编辑:程序博客网 时间:2024/06/13 12:34
# encoding: utf-8#E6.3-2.rbclass StudentClass@@count=0def initialize@@count+=1enddef StudentClass.student_countputs "This class have #@@count students."endendp1=StudentClass.newp2=StudentClass.newStudentClass.student_count # This class have 2 students.p3=StudentClass.newp4=StudentClass.newStudentClass.student_count # This class have 2 students.=begin This class have 2 students.This class have 4 students.请按任意键继续. . .=end