7.22通过对象的引用访问对象中的成员

来源:互联网 发布:石油计量表软件 编辑:程序博客网 时间:2024/05/29 09:19
/*通过对象的引用访问对象中的成员
*/


#include<iostream>
using namespace std;
class Test{
public:
void Set(char ch){c=ch;}
void Show(){cout<<"char in Test is:"<<c<<endl;}
private:
char c;
};
int main()
{
Test test;
test1.Set('a');
Test &refTest=test1;
test1.Show();
refTest.Show();
return 0;
}
0 0