文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++中的sizeof

C++中的sizeof

时间:2011-06-09  来源:池塘里的潜艇

sizeof 返回一个对象或类型名的字节长度。

 

int *pi = new int[13];
cout << "pi:\t" << sizeof(pi)  << endl;
cout << "*pi:\t" << sizeof(*pi) << endl;

string st1("fr");
string st2("a submarine");
string *ps = &st1;
cout << "st1:\t" << sizeof(st1) << endl;
cout << "st2:\t" << sizeof(st2) << endl;
cout << "ps:\t" << sizeof(ps)  << endl;
cout << "*ps:\t" << sizeof(*ps) << endl;

cout << "short:  \t"  << sizeof(short)    << endl;
cout << "short *:\t"  << sizeof(short *)  << endl;
cout << "shout &:\t"  << sizeof(short &)  << endl;
cout << "short[3]:\t" << sizeof(short[3]) << endl;

输出:

pi:     4
*pi:    4
st1:    32
st2:    32
ps:     4
*ps:    32
short:          2
short *:        4
shout &:        2
short[3]:       6
相关阅读 更多 +
排行榜 更多 +
耶小兔子2

耶小兔子2

休闲益智 下载
nba2k20豪华版

nba2k20豪华版

体育竞技 下载
画线征服火柴人安卓版

画线征服火柴人安卓版

动作格斗 下载