1 double a = 10; 2 int b = static_cast<int>(a);
1 const char* szA = "test"; 2 char* szB = const_cast<char*>(szA);
1 class Base 2 { 3 public: 4 virtual void test(){} //基类必须有虚函数 5 }; 6 7 class Child : public Base 8 { 9 public: 10 void print(){ cout << "child::base" << endl; } 11 }; 12 13 Base* pBase = new Base(); 14 Child* pChild = dynamic_cast<Child*>(pBase); 15 pChild->print();
1 typedef void (*FuncPtr)(); 2 FuncPtr funcPtrArray[10]; 3 int doSomeing(){return 0;} 4 5 funcPtrArray[0] = reinterpret_cast<FuncPtr>(&doSomeing);