#include <iostream>
using namespace std;

class tr{
private:
int i;
public:
tr(
int n)
{
i
= n;
}
void set(int n)
{
i
= n;
}
int get()
{
return i;
}
};
//以引用方式传递
#if 1
void sqr(tr &ob)
{
ob.
set(ob.get()*ob.get());
cout
<<"ob.i="<<ob.get()<<endl;

}
#endif

//以值方式传递
#if 0
void sqr(tr ob)
{
ob.
set(ob.get()*ob.get());
cout
<<"ob.i="<<ob.get()<<endl;

}
#endif

//以指针方式传递
#if 0
#define POINT
void sqr(tr *ob)
{

ob
->set(ob->get()*ob->get());
cout
<<"ob.i="<<ob->get()<<endl;

}
#endif
int main()
{
tr obj(
10);//定义一个类,并对其进行初始化
#ifdef POINT
sqr(
&obj);
#else
sqr(obj);
#endif
cout
<<"obj.i="<<obj.get()<<endl;

return 0;
}