zoukankan      html  css  js  c++  java
  • 类的引用类型成员

    1. From http://blog.csdn.net/hello_shadow/article/details/7007383
    2. #include <iostream>  
    3. using namespace std;  
    4. class Object  
    5. {  
    6.     int &count;  
    7.     public:  
    8.         Object(int &cou):count(cou){};  
    9.         //如果函数为Object(int cou)则count引用了形参。  
    10.         ~Object(){};  
    11.         void SetValue(int cou)  
    12.         {  
    13.             count=cou;  
    14.         }  
    15.         void Display()  
    16.         {  
    17.             cout<<"the value of count in Object:"<<count<<endl;  
    18.             cout<<"the address of count in main:"<<&count<<endl;  
    19.         }  
    20. };  
    21.   
    22. int main()  
    23. {  
    24.     int count=10;;  
    25.     Object obj(count);  
    26.     obj.SetValue(9);  
    27.     obj.Display();  
    28.     cout<<"the value of count in main:"<<count<<endl;  
    29.     cout<<"the address of count in main:"<<&count<<endl;  
    30.     return 0;  
    31. }  
  • 相关阅读:
    attr 修改IMG src
    64转2
    :eq
    DOM0和D0M2级事件
    c's's透明度
    span标签 宽度无效解决方案
    CSS 点击事件
    input点击后的 默认边框去除
    js
    CSS 的 ID 和 Class 有什么区别,如何正确使用它们。
  • 原文地址:https://www.cnblogs.com/codec/p/3384589.html
Copyright © 2011-2022 走看看