(01) you need to store the data related to an object in the form of attributes. You also need to divide the functionalities of a class into logical units called methods. 以属性的形式存储与对象相关的数据。 方法是将类的功能划分为逻辑单元。 (方法一个用途:通过reuse方法里的代码perform repetitive tasks)
public : share its member variables and member functions with other class private: 对其他class的对象和方法 hide 它的成员变量和成员函数 protected : 除了subclass,对其他class的对象和方法 hide 它的成员变量和成员函数
The internal access specifier allows a class to expose its member variables and member functions to other class functions and objects within the assembly in which the member is defined. internal访问符允许一个类将其成员变量和成员函数expose 给other class的功能和对象,前提是成员被定义在other class里面 (记住expose)
protected internal : 有两个单独访问符的部分功能,组合。In addition,it allows access to the derived classes outside the assembly. 区别是:internal member are accessible only within the same assembly, 而组合类的成员 are not accessible even from the sub classes in other assembly.
(02) When you define a method,you can include a list of parameters in the parenthese following the method name. 用方法传递信息(pass information),在方法名字后面的圆括号(parenthese)里加入参数就行。 分两步: 1 declare parameterized methods声明 2 call parameterized methods 调用 例如: void add( int x,int y) { return x+y; }
(03)optional arguments allow you to omit arguments when calling methods.This is done by assigning default values to the arguments while defining a method. When a call is made to the function,arguments [ whose values are not passed ] get the default values. 可选参数允许在调用方法时省略参数。这是在定义方法时通过将默认值赋值给参数来实现的。当调用函数时,不传递其值的参数将获得默认值。 (记住omit )