有一段代码如下: #include "stdio.h" void main(void){ class A {}; class B : virtual public A {}; class C: public A {}; class D: public B, public C {}; class E: virtual public B, virtual public C {}; printf("sizeof(A) = %d\n",sizeof(A)); printf("sizeof(B) = %d\n",sizeof(B)); printf("sizeof(C) = %d\n",sizeof(C)); printf("sizeof(D) = %d\n",sizeof(D)); printf("sizeof(E) = %d\n",sizeof(E)); } ...
by notcat - C/C++ - 2009-09-01 19:11:24 阅读(2178) 回复(3)
研究了一下虚拟继承时,对象的内存分布模型,写了下面这个小程序
#include
#include
// world.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
runq-sz – The average number of kernel threads in memory waiting for a CPU to run. Typically, this value should be less than 2. Consistently higher values mean that the system may be CPU bound.
请教高手有关c++中的派生、多态和虚函数的问题。 以下是我做的测试程序, 基类 class A { public : A ( const char* v_name ); protected : virtual void updateSelf( const char * obj){cout << "run in A class " << endl;}; private : void update( const char * v_obj){ updateSelf ( const char * v_obj)}; } 派生类 class B { public : B ( const char* v_name ); protected : virtual void updateSelf(...
/* * Created on 2004-8-31 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ /** * @author diyer6 * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ /* 类的继承 1、在java中通过关键字 extends 继承一个已有的类,被继承的类成为父类(基类),新的类...