Skip to content

Commit 41c5c95

Browse files
authored
Translate 02member.md
1 parent db780ae commit 41c5c95

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

docs/en/quickstart/05class/02member.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
lastUpdate: true
33
---
44

5-
# 类的成员
5+
# Member of class
66

7-
和Java类似,在MCFPP中,类的成员包括属性和方法。属性是类的数据成员,用来存储对象的数据;方法是类的函数成员,用来操作对象的数据。类的成员可以通过`.`操作符来访问。
7+
Similar to Java, in MCFPP, members of class include attributes and methods. Attributes are the data members, used to store the data of the object; methods are the function of class member, used to operate the data of the object. Member of class can access by `.` operator.
88

9-
## 属性
9+
## Attributes
1010

11-
属性是类的数据成员,用来存储对象的数据。属性的定义语法如下:
11+
Attributes are the data member of class, used to store the data of a object. The grammar to define attributes is shown below:
1212

1313
```mcfpp
1414
class A{
@@ -17,11 +17,11 @@ class A{
1717
}
1818
```
1919

20-
上述代码定义了一个类`A`,它有两个属性`a``b``a`是一个整数类型的属性,没有初始化;`b`是一个整数类型的属性,初始化为`5`
20+
The code before defined a class `A`, it has two attributes `a` and `b`. `a` is a integer attribute, not initialized; `b` is a integer attribute, initialized as `5`.
2121

22-
## 方法
22+
## Method
2323

24-
方法是类的函数成员,用来操作对象的数据。方法的定义语法如下:
24+
Methods are the function member of class, used to operate the data of the object. The grammar to define a method is shown below:
2525

2626
```mcfpp
2727
class A{
@@ -31,7 +31,7 @@ class A{
3131
}
3232
```
3333

34-
在方法中使用`this`关键字可以访问对象的属性。例如:
34+
Use keyword `this` can access the attributes of the object,such as:
3535

3636
```mcfpp
3737
class A{
@@ -42,13 +42,13 @@ class A{
4242
}
4343
```
4444

45-
## 访问控制
45+
## Access control
4646

47-
MCFPP中,类的成员可以使用`public``protected``private`关键字来控制访问权限。默认情况下,类的成员是`private`的。
47+
In MCFPP, members of class can use keywords `public`, `protected` and `private` to control the access rights. Default, members of class are `private`.
4848

49-
- `public`公有的,可以被外部访问。
50-
- `protected`受保护的,可以被子类访问。
51-
- `private`私有的,只能在类的内部访问。
49+
- `public`public, accessible to outside.
50+
- `protected`protected, accessible to subclasses.
51+
- `private`private, only can access in the class.
5252

5353
```mcfpp
5454
class A{
@@ -59,16 +59,16 @@ class A{
5959
6060
class B: A{
6161
void test(){
62-
a = 1; #合法
63-
b = 2; #合法
64-
c = 3; #编译错误
62+
a = 1; # Allowed
63+
b = 2; # Allowed
64+
c = 3; # Error
6565
}
6666
}
6767
6868
func test(){
6969
A obj = new A();
70-
obj.a = 1; #合法
71-
obj.b = 2; #编译错误
72-
obj.c = 3; #编译错误
70+
obj.a = 1; # Allowed
71+
obj.b = 2; # Error
72+
obj.c = 3; # Error
7373
}
7474
```

0 commit comments

Comments
 (0)