早教吧 育儿知识 作业答案 考试题库 百科 知识分享

为什么编译时说xi和yi都是未说明的标识符,#includeusingnamespacestd;classimaginary{public:\x05imaginary(doublea,doubleb)\x05{\x05\x05x=a;\x05\x05y=b;\x05}\x05friendimaginaryadd(imaginary&i1,imaginary&i2);\x05friendimagi

题目详情
为什么编译时说xi和yi都是未说明的标识符,
#include
using namespace std;
class imaginary
{
public:
\x05 imaginary(double a,double b)
\x05 {
\x05\x05 x=a;
\x05\x05 y=b;
\x05 }
\x05 friend imaginary add(imaginary &i1,imaginary &i2);
\x05 friend imaginary sub(imaginary &i1,imaginary &i2);
\x05 friend imaginary mul(imaginary &i1,imaginary &i2);
\x05 friend imaginary dev(imaginary &i1,imaginary &i2);
\x05 void show();
private:
\x05 double x,y,xi,yi;
};
imaginary add(imaginary &i1,imaginary &i2)
\x05 {
\x05\x05 i1.xi =i1.x+i2.x;
\x05\x05 i1.yi =i2.y+i1.y;
return i1;
\x05 }
\x05 imaginary sub(imaginary &i1,imaginary &i2)
\x05 {
\x05\x05 i1.xi=i1.x-i2.x;
\x05\x05 i1.yi=i1.y-i2.y;
\x05return i1;
\x05 }
\x05 imaginary mul(imaginary &i1,imaginary &i2)
\x05 {
\x05\x05 i1.xi=i1.x*i2.x-i1.y*i2.y;
\x05\x05 i1.yi=i1.x*i2.y+i1.y*i2.x;
\x05return i1;
\x05 }
\x05 imaginary dev(imaginary &i1,imaginary &i2)
\x05 {
\x05\x05 i1.xi=(i1.x*i2.x+i1.y*i2.y)/(i2.x*i2.x+i2.y*i2.y);
\x05\x05 i1.yi=(i1.y*i2.x-i1.x*i2.y)/(i2.x*i2.x+i2.y*i2.y);
return i1;
\x05 }
\x05 void show(){
\x05 if(yi
▼优质解答
答案和解析
将void show(){
\x05 if(yi