• 面向对象,全局函数和成员函数之间的转换


    class A
    {
    private:
     int a;
     int b;
    public:
     A(int a, int b)
     {
      this->a = a;
      this->b = b;
     }
     A Test(A &aa)
     {
      A temp = A(this->a + aa.a, this->b + aa.b);
      cout << temp.a << "b:" << temp.b << endl;
      return temp;
     }
     A &Test1(A &Aa)
     {
      this->a = this->a + Aa.a;
      this->b = this->b + Aa.b;
      return *this;
     }
     void print()
     {
      cout << this->a << "b:" << this->b << endl;
     }
    };
    void main()
    {
     A a1(1, 2);
     A a2(3, 4);
     a1.Test1(a2);
     //a2.Test(a1);
     a1.print();
     
     system("pause");
    }
  • 相关阅读:
    【bzoj1010】[HNOI2008]玩具装箱toy
    bzoj 3173
    bzoj 1179
    bzoj 2427
    bzoj 1051
    bzoj 1877
    bzoj 1066
    bzoj 2127
    bzoj 1412
    bzoj 3438
  • 原文地址:https://www.cnblogs.com/jefy/p/9404388.html
Copyright © 2020-2023  润新知