求兩個向量的內(nèi)積?
#include <iostream>
using namespace std;
class V
{
double x,y;
public:
V(){}
V(double a,double b)
{
x=a;
y=b;
}
friend V operator*(V a,V b)
{
V c;
c.x=a.x*b.x;
c.y=a.y*b.y;
return c;
}
void show()
{cout<<x<<" "<<y<<endl;}
};
int main()
{
V v1(1,3),v2(2,5),c3;
V *p1,*p2;
p1=&v1;
p2=&v2;
c3=(*p1)*(*p2);
c3.show();
return 0;
}
上一篇華為兒童賬號怎么登錄
下一篇什么是科技云