//
// main.cpp
// project
//
// Created by 徐伟 on 6/15/16.
// Copyright © 2016 fizz_i. All rights reserved.
//
#include <iostream>
using namespace std;
class Sample
{
private:
int x;
public:
Sample() {}
Sample (int a){x=a;}
void disp(){cout<<"x="<<x<<endl;}
Sample operator+(Sample &s);
};
Sample Sample:: operator+( Sample &s)
{
return Sample(x+s.x);
}
int main()
{
Sample obj1(20);
Sample obj2(20);
Sample obj3;
obj3=obj1+obj2;
obj3.disp();
return 0;
}
第十二周阅读程序2
最新推荐文章于 2022-08-07 19:09:07 发布