现在的位置: 首页 > 综合 > 正文

通用 求解 数据结构 size 函数

2013年03月18日 ⁄ 综合 ⁄ 共 315字 ⁄ 字号 评论关闭

#include <iostream.h>
#pragma pack(1)
class test
{
 public:
 virtual ~test();
 private:
 int a;
 double d;
 float c;
 long long l;
};
#pragma pack()
template <typename T>
void sizeoftype()
{
  T *t = 0;
  t++;
  cout << t <<endl;
}

int main()
{
 sizeoftype<int>();
 sizeoftype<double>();
 sizeoftype<float>();
 sizeoftype<long long>();
 sizeoftype<class test>();
}

抱歉!评论已关闭.