typedef int INT;
#ifndef UNICODE typedef char TCHAR; #else typede wchar_t TCHAR; #endif 如果当前环境支持Unicode,那么TCHAR就会等价于wchar_t宽字符类型,否则TCHAR等价于char类型,那么程序员就可以借助TCHAR来隐藏具体的编译环境。
#define INT int
#define pINT int*; typedef int *pINT2; pINT a, b; pINT2 c, d;
#include <iostream> using namespace std; typedef int* _int, _int2; //_int是int*类型,而_int2是int类型 typedef int INT; //INT是int类型 typedef _int *INT2, *INT3; //INT2和INT3都是*_int类型,也就是**int类型 typedef void (*funcptr)(double); //funcptr是一个函数指针类型,指向返回值为void,接受一个double类型参数的函数 typedef union { char c; int i; bool b; } Foo; //Foo是一个联合体 typedef class TestClass { int a, b, c; public: TestClass(int a, int b, int c) : a(a), b(b), c(c) { } } TESTCLASS; //TESTCLASS就是TestClass类 void hello(double x) { //funcptr可以指向这个函数 cout << x << endl; } int main() { INT a = 6; _int2 e = 7; _int c = &a; INT2 b = &c; INT3 d = &c; cout << a << e << *c << **b << **d << endl; funcptr p = hello; p(3.333); cout << p << endl; Foo foo; foo.i = 65; cout << foo.b << foo.c << foo.i << endl; TESTCLASS tc(1, 2, 3); system("pause"); return 0; } |
|
来自: SamBookshelf > 《C 》