标签:
1、隐身转换
short a=2000; int b; b=a; //b= (int)a; #include <iostream> using namespace std; class A {}; class B { public: // conversion from A (constructor): B (const A& x) {} // conversion from A (assignment): B& operator= (const A& x) {return *this;} // conversion to A (type-cast operator) operator A() {return A();} }; int main () { A foo; B bar = foo; // calls constructor bar = foo; // calls assignment foo = bar; // calls type-cast operator return 0; }
dynamic_cast <new_type> (expression)
reinterpret_cast <new_type> (expression)
static_cast <new_type> (expression)
const_cast <new_type> (expression)
typeid().name
标签:
原文地址:http://www.cnblogs.com/hinice/p/5390519.html