初步了解C++指针
1. 可变大小
在C++中,内存的计量单位是字节或位。关键字 sizeof 返回其参数的大小,以字节为单位。以下程序使用 sizeof 来确定不同变量类型的大小:
// VariableSize - 输出每种变量类型的大小
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[]) {
bool b;
char c;
int n;
long l;
long long ll;
float f;
double d;
long double ld;
cout << "sizeof a bool = " << sizeof(b) << endl;
cout << "sizeof a char = " << sizeof(c) << endl;
cout << "sizeof an int = " << sizeof(n) << endl;
cout << "sizeof a long = " << sizeof(l) << endl;
cout << "sizeof a long long =
超级会员免费看
订阅专栏 解锁全文
316

被折叠的 条评论
为什么被折叠?



