#include <iostream>
//typedef和#define
typedef int prablint;
#define prablchar char
typedef int* prabl_int_p;
#define prabl_char_p char*
int main()
{
using namespace std;
prablint a = 0;
prablchar b = 'a';
prabl_int_p c,d;
prabl_char_p e,f;
cout << sizeof(a) << endl;
cout << sizeof(int) << endl;
cout << sizeof(b) << endl;
cout << sizeof(char) << endl;
cout << sizeof(c) << "," << sizeof(int*) << endl;
cout << sizeof(d) << "," << sizeof(int*) << endl;
cout << sizeof(e) << "," << sizeof(char*) << endl;
cout << sizeof(f) << "," << sizeof(char*) << endl; //f是char型,不是char*。所以用typedef是更安全的
system("PAUSE");
return 0;
}
回复 更多评论