相同类的不同对象执行相同成员函数输出不同结果
#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 test1,test2;
test1.Set('a');
test2.Set('b');
test1.Show();
test2.Show();
return 0;
}
#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 test1,test2;
test1.Set('a');
test2.Set('b');
test1.Show();
test2.Show();
return 0;
}