C + + Rookie starter concept A

Source: Internet
Author: User

    • destructors provide the resources that can be released before an object is deleted

Release using delete.

The function before plus ~ is the representation that the function is a destructor.

    • constructor Function The function of a class name constructor is to initialize the data member of the object.

Create a class without writing any constructors, the system automatically generates a default parameterless constructor written

You do not need to define a return value type. There is no specific return value.
When all objects are created, they need to be initialized before they can be used.
In a class, you can have more than one constructor, because the function name is the same, onlyto differentiate by a parameter list
When multiple constructors appear in a class, their presence is overloaded.
The constructor is called when the object is created, used for initialization, and the initialization action is performed only once.

    • The stack is automatically assigned by the system and is faster. System Maintenance

Like the case of the data, take out the bottom of the things to save after taking, and then save first.

    • The heap is allocated by new memory, the speed is relatively slow, the most convenient to use. Programmer Maintenance

Like a tree that's upside down

A sorted, tree-shaped data structure with a value for each node. Typically, the data structure of a heap refers to a two-fork heap.

The heap is characterized by the minimum (or maximum) value of the root node, and the two subtrees of the root node are also a heap. Because of this feature of the heap, it is commonly used to implement priority queues.

    • Non-contiguous records in the list memory are concatenated with pointers.

    • Header File General header file provides an interface for the source file to provide the implementation.

    • The virtual function is modified by the virtual keyword member function

    • Pure virtual function pure virtual function is a special virtual function, in many cases, in the base class can not give a meaningful implementation of virtual function, and declare it as pure virtual function, its implementation is left to the derived class of the base class to do.

eg:virtual void eat () = 0;

    • base class & Derived class base class is the parent class, and the derived class is the child class

    • overriding (Override) derived classes redefine the virtual function of the base class, which overrides the virtual function of the base class (polymorphism)

The function of the base class is virtual

    • C + + Inherits the existing class used to derive the new class as the base class, also known as the parent class. A new class derived from a base class is called a derived class, also known as a subclass.

The successor is the parent class, the successor is the subclass, the ultimate parent class is the Object

    • The redefine (redefine) derived class is redefined for the member function of the base class, that is, the derived class defines a function whose name is the same as the function name in the base class.

    • The overloaded (overload) function has the same name, but its number of parameters or order, or type, is different, but cannot be judged by the return type.

    • operator Overloading operator overloading is primarily object-oriented.

Format: function type operator operator name (formal parameter table column)
Eg:void operator () () is overloaded with () this operator

    • The callback function invokes the method you specified when the system is in the process of something happening. This method is defined first and waits for the system to invoke it.

    • API function operating system in addition to coordinate application execution, memory allocation, system resource management, but also a large service center,

Call this service center service (each service is a function), can help the application to open the window, draw graphics,

For the purpose of using peripheral devices, these functions serve objects that are applications

    • thread threads, which are control flows in a single order in the process. Also known as light weight process

A thread is the smallest unit in which the operating system is able to perform operational scheduling

    • definition and implementation of class Using the keyword class in C + +

Generally, the property members of a class should be set to private, and public only to the function interfaces that are used by the outside world.
An object that creates a class is called an instantiation of the class

1  class point{          2 public:3         void setpoint (int x,int y), 4         void Printpoint (), 5 private:6          int Xpos;7
   int ypos;8};       The end part of the semicolon cannot be omitted.

    • reference references are introduced in C + +,& identity function , format: type identifier & reference name = target variable name;

Eg:int A;      int &la=a; That defines the reference LA, which is a reference to the variable A, which is the alias
Cannot create a reference to an array

    • Common Reference format: const type identifier & reference name = Target variable name, cannot be modified by reference to the value of the target variable

C + + Rookie starter concept A

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.