First, method overloading:
1, two functions have the same name, and they form the overloaded relationship of the method.
2, overloaded functions, must have different parameter types or the number of parameters with other functions
Note: "ctrl+shift+ SPACEBAR" to view overloaded methods
Second, the package
1. Fields of the class:
Classes can be directly defined variables, which are called class fields, also called member variables.
2. Properties of the class:
is a special field that is used to transfer data for other fields, with two methods
3. Methods for encapsulating fields:
(1) By right-clicking on the field "Refactor" "Encapsulate Field" "OK" implementation
(2)
Read accessor
get {return Name;}
Write accessors
set {
if (value. LENGTH<=3)
Name = value;
}
Third, static members: (Static)
Cannot operate through the object of a class, only by using the class name.
Static members are not within the scope of the data type rule template for the object being created
Iv. the difference between a class and an object:
Class is a user-defined data type and is a template
An object is a variable created by a template.
The relationship between a class and an object is a one-to-many relationship, and the class can create N objects based on the class.
The constructor of the class:
A constructor is a function with the same name as the class name and no return value.
Default no return value, no parameter, no function body, but you can write your own overload
Constructors exist by default for each class, with at least one constructor
Constructors are the portals of classes when creating objects
The constructor is the function that is called after new, and it has all the functions of the other normal functions
The constructor is used to initialize the object when the class's member variable is given the initial value
And the data transfer between the classes and classes
Six, modifier:
Public, scoped to the entire namespace (class library), and other places where this namespace is referenced
Private, can only be used for the current class
Protected protected, for the current class, and for subclasses
Vii. Inheritance:
Subclasses inherit from the parent class, inheriting a class by adding a colon after the class
Once an inheritance relationship is formed, the object of the subclass can use the public properties and method functions in the parent class
Subclasses can be converted to a parent class, but the parent class is not necessarily able to turn into subclasses
The parent class object can be converted back only if the parent object is converted by a subclass object.
From which subclass, you can only go back to that subclass.
Objects that are built directly from the parent class's constructor and cannot be converted to child class objects
When a method with the same name as the parent class is overridden in a subclass,
By which class the object points out the method, corresponding to that class inside the method content
Overridden method, if you add virtual in the parent class to override the subclass,
When you convert from a subclass object to an object of the parent class type, the child class method is called through the parent class object
Eight, Abstract:
1, abstract class: Class name classes preceded by abstract
Abstract classes cannot create objects (instances) and can only be used as parent classes in an inheritance relationship
Other usages have the same inheritance usage as ordinary classes
2. Abstract Method:
Can only be written in abstract classes
The content of the method must be overridden by override in the subclass
If not, then the subclass becomes an abstract class by default.
You have to inherit it somewhere else.
3, abstract attributes, note that the property is not a field.
As with abstractions, you need to rewrite them.
Nine, Interface:
A class can inherit only one parent class, but a class may inherit multiple interfaces
Interface cannot create its own instance, the interface cannot write segments, attributes
The method in the interface cannot have the method content, must be in the subclass to implement,
Implementation of the interface by the name of the point out method to achieve
Object-oriented (overloaded, encapsulated, inherited, abstract)