平面向量头文件定义重载出错,望解决
  • 板块学术版
  • 楼主FanofFuSu
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/7 21:21
  • 上次更新2024/6/8 09:43:24
查看原帖
平面向量头文件定义重载出错,望解决
1004178
FanofFuSu楼主2024/6/7 21:21
[Error] must take either zero or one argument

代码如下

#include<bits/stdc++.h>
#ifndef vectin2_h
#define vectin2_h
using namespace std;

class vectin2{
private:
public:
	double x;double y;
	double Mode,Tan;
	vectin2(double alpha,double beta):
	x(alpha),y(beta){
		Mode=sqrt(alpha+beta);
		Tan=beta/alpha;
	}
	vectin2 operator +(vectin2 a,vectin2 b){
		vectin2 ve_;
		ve_.x=a.x+b.x,ve_y=a.y+b.y;
		return ve_;
	}
	vectin2 operator -(vectin2 a,vectin2 b){
		vectin2 ve_;
		ve_.x=a.x-b.x,ve_y=a.y-b.y;
		return ve_;
	}
	double operator *(vectin2 a,vectin2 b){
		return a.x*b.x+a.y+b.y;
	}//点乘
	double operator *(vectin2 a,vectin2 b,double theta){
		return a.Mode*b.Mode*cos(theta);
	}//点乘
	void operator =(vectin2 a) {
		this->x=a.x,
		this->y=a.y;
	}
}; 
#endif
2024/6/7 21:21
加载中...