Private, Only the class can be accessed directly,
Protected, which can be accessed directly within the class and subclass,
Public, which can be accessed directly by anyone.
The inheritance type indicates the parent class.
Example:
Class {
Public:
Int A1;
Protected:
Int A2;
Private:
Int A3;
};
A;
A. A1; // OK
A. A2; // Error
A. A3; // Error
Class B: Public {
Public:
Void FB (){
A1; // OK
A2; // OK
A3; // error;
}
};
B;
B. a1, B. a2, B. a3 and. a1,. a2,. like A3, because it is Class B: Public A, it is equivalent to putting a to the public part of B.
For example
Class B:PrivateA {};
Then
B. A1, B. A2, and B. A3 all have errors, because it is equivalent to putting A to B'sPrivateIn part, from B, all three variables arePrivate.
PartialThe keyword is used to divide your class into multiple parts, and the compiler will combine multiple parts.
Example:
PublicPartialClass sampleclass
{
Public void methoda ()
{
}
}
PublicPartialClass sampleclass
{
Public void methodb ()
{
}
}
And
Public class sampleclass
{
Public void methoda ()
{
}
Public void methodb ()
{
}
}
Is equivalent.