reprint: http://www.cnblogs.com/jerry19880126/p/3616999.html
工欲善其事, its prerequisite, let's start with the Visual Studio Tools, step-by-step like the following:
First select the c/c++-> command line on the left, and then write the/d1
Memory layout and layout of the C ++ virtual inheritance class
1. Single virtual inheritance
It is only for analysis, but it does not play a major role in practice. The memory layout of the derived class objects related to virtual inheritance is
1. destructor and virtual destructorIf the destructor of the base class is virtual, The destructor of its derived class are virtual.This will cause: When the derived class destructor, all of its basic class destructor will be called.Otherwise, only
This article mainly tests the class size, including empty classes, static and non-static variables, virtual and non-virtual single inheritance and multi-inheritance classes, and class or object
Test whether the virtual table and virtual pointer
Introduction has never written a conceptual article, because I think that these conceptual things are written in the books and are very detailed and useless, and today I have a whim to write, Here is a discussion of the virtual base class,
1. Generic class without inheritance:In the case of a virtual function, the class adds a hidden member, a virtual function table pointer to a virtual function table, and the virtual function table is the address of each virtual function of the class.
The memory size calculation of the class in the case of virtual inheritanceWhen there are multiple virtual functions in each base class, and in the case of virtual inheritance, how the memory is allocated and how the class size is computed, the
1. Generic class without inheritance:In the case of a virtual function, the class adds a hidden member, a virtual function table pointer to a virtual function table, and the virtual function table is the address of each virtual function of the class.
Virtual functions (virtual keyword) and polymorphism one: A pointer problem in inheritance.
1. A pointer to a base class can point to a derived class object. When a base class pointer points to a derived class object, the pointer can only
Http://www.cnblogs.com/fly1988happy/archive/2012/09/25/2701237.html1. polymorphicIn object-oriented languages, many different implementations of interfaces are polymorphic. Polymorphism refers to an instance (object) of a child class with a pointer
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.