给出类:classthree—d{intx,y,z;public:three—d(inti,intj,intk){x=i,y=j,z=k;}three—d{x=0;y=0;z=0;}voidget(inti,intj,intk){i=x;j=y;k=z;}};针对给出的类,重载“+”运算符,以便使“+”运算符可以接受下面的运算类型:ob+int;imt+ob;其中ob为three—d类对象。
#includeclassthree—d{intx,y,z;public:three—d(inti,intj,intk){x=i,y=j,z=;}three—d{x=0;y=0;z=0;}voidget(inti,intj,intk){i=x;j=y;k=z;}friendthree—doperator+(therr—da,intb);friendthree—doperatot+inta,three—db);};three—doperator+(therr—da,intb);{three—dc;c.x=a.x+b;c.y=a.y+b;c.z=a.z+b;returnc;}three—doperator+(inta,three—db){three—dc;c.x=a+b.x;c.y=a+b.y;c.z=a+b.z;returnc;}main{three—dop1(1,2,3),op2(4,5.6);op1=op1+10;op2=10+op2;}