Imagine a problem:If we need to give a super-class method to achieve a more powerful function, that is, the enhanced version of the super-class, what will generally do?Inherited?Too Young Too simple!Take a look at the following example:When we need
1, the object of the upper transformationYou cannot call and use new members and variables of the subclass object, and you cannot call the new method of the child class.On a transformed object, you can access the subclass inherited or hidden member
1. Concept of inheritanceInheritance is an attribute of C + +, meaning that a new class is derived from an existing class, whereas a derived class inherits some of the private members and member functions of the base class.Public inheritance is the
1. Single DutyWhether in the design class, interface or method, a single responsibility is everywhere, the definition of a single responsibility: we define responsibility as the cause of the system change. All at the time of defining classes,
The policy pattern defines a series of algorithms, encapsulates each algorithm, and allows them to be replaced with each other, and the policy pattern makes the algorithm independent of the customers who use it. The policy pattern enables these
One, abstract class:
Abstract classes are special classes, but cannot be instantiated; In addition, there are other attributes of the class; It is important that abstract classes can include abstract methods, which are not possible for ordinary
The sixth chapter of effective C + +: Inheritance and object-oriented design
Make sure that your public inherits the is-a relationship from the mold. Student is a person, so student can inherit public from person. Conceptually, a square is a
In "Think in Java" There is a sentence: Reuse code is one of Java's many compelling features. But to be a revolutionary language, it's not enough to just copy the code and change it, and it has to be able to do more. The most noticeable in this
DataType-------------Basic data types1.2 int1.byte short int long float double2.boolean[true,false]3.char reference types1.class2.interface3.[] Function--------function, methods, methodEncapsulates the function code.Definitions cannot be nested.
String manipulation(1) String str = new string (); equivalent to String str = "(void)"; (point to an empty string), not String str; (objects that do not point to any strings)(2) string initialization can contain alternative parts such as%s,%d,%x,
InheritedIntroducedInheritance is the derivation of new classes from existing classes, which can absorb data properties and behaviors of existing classes, and can extend new capabilities. Inheritance is often said to be the is-a relationship.
Introduced
The decorator pattern dynamically attaches responsibility to the object. To extend functionality, adorners provide a more flexible alternative than inheritance.
Mind Mapping
There is such a project to make a restaurant reservation
Definition 1: If the object O1 for each type is T1, there is an object O2 of type T2, so that all program P defined by T1 is substituted for O1 for all object O2, the behavior of the program P is not changed, then the type T2 is the subtype of the
There must be a lot of people who are just as confused about the name of this principle as I was when I first saw it. The reason for this is that the principle was first introduced in 1988 by Barbara Liskov, a woman in the MIT family name.
(The
interface cannot be instantiated;The method in the interface has no method body {};The class that inherits the interface must implement the method defined in the interface;Class can be instantiated, you can define your own fields, properties,
OC point syntax and variable scopes
One, point grammar
(a) Understanding point grammar
Declare a person class:
Copy Code code as follows:
#import
@interface Person:nsobject{int _age;//defaults to @protected}
-(void)
Responsibility chain Model
The Chain of responsibility (CoR) mode is also called a duty chain pattern or a chain of responsibilities, and is one of the behavioral patterns that constructs a series of objects of classes that assume different
I. About annotations
Annotations in CSS are important when you create a XHTML+CSS Web site. When you create CSS styles, you should keep the habit of commenting on them. In general, I am accustomed to using the "/* Comment content * * * * *" format
Behavior regulates the requests you can make to objects. Your class, that is, the object, that is, MM, you design her out, and you are very bt, only to her design two behavior: Love Me () and make Love with Me (). Then she would not be able to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.