Types of Modifiers in x++
The first piece of a class is the class declaration.
The class declaration holds the name of the class, the instance variables, and other modifiers.
You can determine the visibility of the variables by using three modifiers:
1) private,
2) protected,
3) and public.
***
If you do not add a modifier, it is presumed to be a public class. However, it is best practice to provide a modifier.
1)Private - Makes the variables only usable within the class that it is defined in.
2)Protected - Makes the variable only usable within the class that it is defined in and any subclass of that class.
3)Public - Makes the variable usable anywhere and is the default modifier.
The following is an example of a class declaration plus declaration of a member variable:
public class CustomerDetails
{
private str custName;
}
Comments
Post a Comment