使用引用重载

  1. void f(int i)  
  2. {  
  3.     cout<<"int";  
  4. }  
  5. void f(int& i)  
  6. {  
  7.     cout<<"int&";  
  8. }   
  9. int main()  
  10. {  
  11.     int x=2;  
  12.     f(x);  
  13.     return 0;  
  14. }  
 
static_cast<void(*)(int&)>(f)(x);去调用引用版本
posted @ 2017-12-11 14:51  杏坛sky  阅读(83)  评论(0编辑  收藏  举报