C ++ 03: On the object-oriented features

A. The benefits of object-oriented

1. maintainable

2. Reusable

3. Scalable

4. Good flexibility

Object-oriented design inheritance is polymorphism through encapsulation the coupling procedure is reduced so that the program more flexible, easily modified, and easy reuse

 

1. Packaging

class A{
 
public:
    A(int a){
 
    }
}

 

2. Inheritance

Virtual inheritance, sometimes diamond inheritance case may occur, then we need to retain only memory structure of a base class to avoid conflicts

class B: public A{
public:
    B(int a,int b):A(a){
 
    }
};
 
class C:public A{
public:
    C(int a,int c):A(a){
    
    }
};
 
//C++允许多继承
class D:public B,public C{
public:
    D(int a,int b,int c):B(a,b),C(a,c),A(a){
 
    }
    
};

 

3. Polymorphism

 

4. Abstract

 

II. Five basic principles of object-oriented

1. Single Responsibility Principle (SRP)

2. Open Closed Principle (OCP)

3. Richter Substitution Principle (LSP)

4. Dependency Inversion Principle (DIP)

5. Interface Segregation Principle (ISP)

 

III. Functional Programming

 

IV. Generic Programming

 

V. metaprogramming

Guess you like

Origin www.cnblogs.com/k5bg/p/11118587.html