What is Class?
上一篇 /
下一篇 2007-11-26 15:06:04
http://www.cplusplus.com/doc/tutorial/classes.html
An object is instantiation of a class.对象是类的实列。
Class would be the type.类就好比类型。
Object would be the variable.对象就好比变量。
A class is declared by key word "class".类用关键字"class"来声明。
Sample(列子):
class class_name/*定义类名为class_name的类*/{
access_specifier1/*member1的被访问属性在这里定义,可以是private,protected和public中的任何一种*/:
member1/*类的成员名*/
access_specifier2;
member2;
......} object_names/*生成一个名字为object_names的对象*/;
class_name is the ID of class.类名是类的标识。
object_name is an optional list of names for object of this class.对象名是某一个类的实列的名字列表中的一个,是可选的,不是必须的,可以在需要使用的时候生成该实列。
access_specifier describe the right of related right member in following scope有效的被访问权限值应该是下列中的任何一个:
1.private私有:members of class are accessible only from within same class or from friend members.类的私有成员只能被该类的成员及其该类成员的朋友。朋友:在该类外,用指令关联的类。
2.protected受保护:members of class are accessiable from within same class or from members or from members of their derived class.类的受保护成员比类的私有成员多一条被访问通路。它可以被该类的衍生类(子类)的成员所访问。
3.public公有:members are accessiable from anywhere where the object is visiable.类的公有成员可以在任何可以访问该类对象的地方被访问到。
收藏
举报
TAG: