c ++ class notes

   Object-Oriented Programming (Object Oriented Programming, OOP) is a computer programming architecture. OOP is a basic principle of a single computer program can play the role of a subroutine unit or a combination of the object. OOP reach the three main objectives of software engineering: reusability, flexibility and scalability. OOP = + Object class inheritance + + + polymorphism message, which is the core concept of classes and objects. The solution space object-oriented programming approach is to simulate as much as possible the human way of thinking, so that the process of software development methods and the methods and procedures as close as possible human understanding of the world, to solve real-world problems, and even have the problem space description of the problem and the problem the same as in the structure, the objective world of abstract entities subject to the problem domain. Object-oriented programming object-core, which assume that the program consists of a series of objects. Class is an abstraction of the real world, includes data representing the static properties and operations on the data, object is an instance of the class. Between objects communicate with each other through message passing to simulate real-world connections between different entities. In object-oriented programming, objects are the basic program module.  (Baidu Encyclopedia)
  In c ++ program, classes are the core-oriented programming methods, may be implemented using a class of data encapsulation and hiding. Class is a logical data encapsulation function, which is an abstract description of the problem. From c language, it is a special type structure. It is defined as a class as follows:
// to the type of people to tell a 
class Animal {    // as the parent class for people class inherits 
    public : // as an interface for external calls 
        Animal ( Double weight): weight (weight) {}; // constructor 
        void eAT () {cout << " eat something " };      // member function 
     private : // private data 
         Double weight; 
}; 

class People: public Animal {   // as a common inheritance Animal 
    public : 
        Pelple ( Double weight, int age):weight(weight),age(age){};
        void say() const {cout<<"说话"};
    private:
        int age;

}
        
    

Object generation:

People A(52.7,18);

Some of the concepts of classes and objects are described.

概念 描述
类成员函数 类的成员函数是指那些把定义和原型写在类定义内部的函数,就像类定义中的其他变量一样。
类访问修饰符 类成员可以被定义为 public、private 或 protected。默认情况下是定义为 private。
构造函数 & 析构函数 类的构造函数是一种特殊的函数,在创建一个新的对象时调用。类的析构函数也是一种特殊的函数,在删除所创建的对象时调用。
C++ 拷贝构造函数 拷贝构造函数,是一种特殊的构造函数,它在创建对象时,是使用同一类中之前创建的对象来初始化新创建的对象。
C++ 友元函数 友元函数可以访问类的 private 和 protected 成员。
C++ 内联函数 通过内联函数,编译器试图在调用函数的地方扩展函数体中的代码。
C++ 中的 this 指针 每个对象都有一个特殊的指针 this,它指向对象本身。
C++ 中指向类的指针 指向类的指针方式如同指向结构的指针。实际上,类可以看成是一个带有函数的结构。
C++ 类的静态成员 类的数据成员和函数成员都可以被声明为静态的。

During class instantiation process should pay attention, class member function only takes one address space, and the data was created following the creation of the object, so the object does not affect the order between each other, while the class member functions is through this pointer to get the data for each object, a pointer to the object of the calling parameters to complete related tasks.

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/yc555/p/11303483.html