C + + Learning notes

Source: Internet
Author: User

1. The difference between a member function, a virtual function, and a pure virtual function class A{public:void Fun1 ();virtual void fun2 ();virtual void fun3 () = 0;} CALSS B:a{public:void Fun1 ();void Fun2 ();void Fun3 ();} int main (void) {b b;B.fun1 ();Call FUN1 in class AB.fun2 ();Call fun2 in Calss B, b::fun2 override A::fun2B.fun3 ();Call Fun3 in Calss B, A::FUN3 is A interfacereturn 0;} 2. If an object is defined locally, the object is automatically deleted at the end of the local function. If it is a new object, the object persists regardless of where the function is run, unless it is manually delete. If you define a pair of objects locally and place them in a container, the container is copying the object into it. After the partial end, the copy of the object is still in. Note: For each destructor of a class, be careful to delete all new in this class, and beware of the new ones being put into the container. Easy to ignore. 3. C + + declares the role of other classes in the first half of a class's header file (before the definition body of the class)? 4. Similar to using Node::addchild; 5. How do I generate a static link library for a dependent project so that it doesn't have to be so slow every time you link? 6. The previous step, assuming that a static library has been generated, this time can not change the static library of things, in order to change, how to change back to the previous? 7. Overload overloading in a C + + program, several functions that are semantically and functionally similar can be represented by the same name, but with different parameters (including type, order), which is function overloading. (1) The same range (in the same Class), (2) The function name is the same, (3) the parameters are different; Note that the return type is not considered in overload resolution and that functions declared in different scopes are not overloaded. Override overrides refer to a derived class function that overrides a base class function, characterized by: (1) a different range (in a derived class and a base class, respectively), (2) a function with the same name, (3) the same parameter, and (4) a base class function must have the virtual keyword. Overwrite: Overrides refer to a function of a derived class that masks a base class function with the same name as the following: (1) If the function of the derived class has the same name as the function of the base class, the parameters are different. At this point, the function of the base class is hidden, whether or not the virtual keyword is present. (2) If the function of the derived class has the same name as the function of the base class, and the parameters are the same, the base class function does not have the virtual keyword. At this point, the function of the base class is hidden (be careful not to confuse with overrides) 8. If you want to implement overriding the parent class function, the parent class function must have the virtual keyword, or the parent class will still be called when the child class overrides the parent class function. Finally, subclasses add override when overriding the parent class function, enhancing readability.

C + + Learning notes

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.