<span =“apple-style-span” style="font-size: 16px; line-height: 24px; ">程式碼轉載自:C++物件導向程式設計 (作者:古頤榛)
[code]
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
double dType;
cout << "int 型態的位元組數 = "
<< sizeof(int) << "bytes\n"; //取得int型態大小
cout << "short 型態的位元組數 = "
<< sizeof(short) << "bytes\n"; //取得short型態大小
cout << "bool 型態的位元組數 = "
<< sizeof(bool) << "bytes\n"; //取得bool型態大小
cout << "變數dType的位元組數 = "
<< sizeof(dType) << "bytes\n"; //取得變數dType的大小
system("PAUSE");
return EXIT_SUCCESS;
}
[/code]