the memory of virtual base class of C++
2007-12-16 23:58
471 查看
class X ...{};
class Y : public virtual X ...{};
class Z : public virtual X ...{};
class A : public Y, public Z ...{};
class A2: public virtual Y, public virtual Z ...{};
int main()...{
cout<<sizeof(X)<<endl; // 1
cout<<sizeof(Y)<<endl; // 4
cout<<sizeof(A)<<endl; // 8
cout<<sizeof(A2)<<endl; // 12 ??
return 1;
}
相关文章推荐
- What’s the behavior when calling an overwritten virtual method in the constructor method of a base class?
- Question 48: In C++, which of the following statements accurately describe a base class destructor calling a virtual function ov
- Parser Error Message: The base class includes the fieldthe type of control (ASP.
- the leak of the memory in c++ 03
- c++中包含empty virtual base class 类的sizeof结果分析
- An easy instance of using the template class in C++
- The NOTE of learning ASP.NET [6] 关于 .NET BCL(Base Class Library,基础类库)
- The memory size of a C++ object instance.
- Life Cycle of the Flex UIComponent Base Class
- The Leak of The Memory in C++ 1.2
- Question 31: A C++ developer wants to handle a static_cast() operation for the class String shown below. Which of the following
- Virtual Memory II: the return of objrmap
- The base class includes the field '...', but its type (...) is not compatible with the type of control (...)
- How to fix the dreaded "java.lang.OutOfMemoryError- PermGen space" exception (classloader leaks)
- Why is the size of an empty class not zero in C++?
- The effective memory management of C++
- Question 33: How can a C++ developer use the placement new syntax to make new allocate an object of class SomeClass at a particu
- C++ philosophy: Changing the accessibility of a class member should never change the meaning of a program.
- C++ - Memory Layout of Virtual Inherit (虚继承的内存布局)
- My priliminary understanding of the relationship between virtual address and physical memory address