Chapter Review:The 1th chapter of effective C + + makes himself accustomed to c++-reading notesEffective C + + 2nd structure/destructor/assignment operation (1)-Reading notes"Effective C + +" 8th custom new and delete-reading notesArticle 05:
Reference: http://www.weixueyuan.net/view/6373.htmlSummarize:A constructor cannot be declared as a virtual function, and a destructor can be declared as a virtual function.After the destructor of the base class is declared as a virtual function, the
Declare the destructor of the polymorphism base class as a virtual function.
Now we want to consider a timer problem. First we create a base class named timekeeper, and then create various derived classes based on it, so that we can use different
Constructor:
C ++ provides constructor to process object initialization. It is automatically executed when an object is created. The name of the constructor must be the same as the class name. It does not have any type or return any value. The
C + + clearly states: when the derived class object is deleted by a base class pointer, and the base class takes a non-virtual destructor, the result is undefined-- The actual execution usually occurs when the derived component of the object is not
Li Jianzhong (Nanjing University of Posts and Telecommunications (Cornyfield@263.net)
Constructor
The constructor initializes the member variables (fields) in the class. The C # class has two constructor types: instance constructor and static
I have been talking about it for a long time. msdn also has a very detailed description, but it does not seem very systematic. I have also done some analysis, but I did not forget to summarize it. This time, I will sort out some information
1. Why do I need to define a virtual destructor?
If oneClass with the virtual function, it needs a virtual destructorFor the following reasons:1) if a class has a virtual function, it is often used as a base class;2) if it is a base class, Its
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.