????//???????????к??????????濪??????????ζ????????????θ?????????????
????//Ч????????t????£?????????????????????·
????//????????γ????о?????????????????????л??д????
????//?????????????????


#include <iostream>
using namespace std;
class demo
{
public:
demo();
demo(int a);
demo(const demo& tmp);
~demo();
const demo& add(const demo & a?? const demo& b);
const demo * constoperator+(const demo & tmp);
void set(int a);
int get()const;
private:
int x;
};
int main()
{
demo fta(5)??ftb(6);
const demo * const fts =fta + ftb;
cout<< "ADD:"<< fts->get()<< endl;
return 0;
}
demo::demo()
{
cout<< "Original constructorrunning... ";
cout<< x <<endl;
}
demo::demo(int a)
{
x = a;
cout<< "Set value constructorrunning... ";
}
demo::demo(const demo & tmp)
{
this->x =tmp.x;
cout<< "Copy constructorrunning... ";
cout<< x <<endl;
}
demo::~demo()
{
cout<< "Destructor running... ";
}
const demo & demo::add(const demo& a?? const demo & b)
{
this->x =a.x + b.x;
cout<< "Two objects... ";
return *this;
}
const demo * const demo::operator+(const demo& tmp)
{
cout<< "Direct memory address accessmode?? no objects will be copied. ";
this->x =this->x + tmp.x;
return this;
}
void demo::set(int a)
{
x = a;
}
int demo::get()const
{
return x;
}