通用 求解 数据结构 size 函数

来源:互联网 发布:科研民工 知乎 编辑:程序博客网 时间:2024/04/30 21:42

#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>();
}


原创粉丝点击