posts - 1,  comments - 0,  trackbacks - 0
  2007年2月14日

#include <iostream.h>
#include <windows.h>
/*
class Test {
public:
 int data;
 int flag;
};

int & getData(Test * test) //const
{
 return (int &)test->data;
}

int main()
{
 Test *test = new Test();
 test->data = 100;
 test->flag = 0;

 cout<<test->data<<"  "<<test->flag<<endl;
 getData(test) = 999;
 cout<<test->data<<"  "<<test->flag<<endl;
 Sleep(1000);
 return 0;
}
*/

class Test {
public:
 int data;
 int flag;
public:
 int & getData(Test * test) const;
};

int & Test::getData(Test * test) const
{
 return (int &)test->data;
}

int main()
{
 Test *test = new Test();
 test->data = 100;
 test->flag = 0;

 cout<<test->data<<"  "<<test->flag<<endl;
 test->getData(test) = 999;
 cout<<test->data<<"  "<<test->flag<<endl;
 Sleep(1000);
 return 0;
}

posted @ 2007-02-14 18:01 风风 阅读(138) | 评论 (0)编辑 收藏
仅列出标题  
<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(1)

随笔档案

链接

搜索

  •  

最新评论