浏览 2409 次
该帖已经被评为隐藏帖
|
|
---|---|
作者 | 正文 |
发表时间:2009-12-24
最后修改:2009-12-24
// Win32ConsoleMemoryTest.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; struct B { int j; }; struct A { int i; B b[0]; }; template<int a> class BT { public: BT() :size(a) { } int size; }; int _tmain(int argc, _TCHAR* argv[]) { const int i = sizeof(B); BT<i> bt; cout<<bt.size<<endl; A a; a.i = 1; B b1; b1.j = 2; B b2; b2.j = 3; A* pA = (A*)(malloc(sizeof(A) + 2*sizeof(B))); memcpy((char*)pA + sizeof(A) ,&b1,sizeof(B)); memcpy((char*)pA + sizeof(A) + sizeof(B),&b2,sizeof(B)); cout<<(pA->b[0].j)<<endl; cout<<(pA->b[1].j)<<endl; cin.get(); }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-12-25
.....关键技术,差点没吓死。。
|
|
返回顶楼 | |
发表时间:2009-12-25
ray_linn 写道 .....关键技术,差点没吓死。。 高手,这都被你发现啦。 |
|
返回顶楼 | |
发表时间:2009-12-26
在隐藏之前留个爪
|
|
返回顶楼 | |