📄 floatnm.h
字号:
// FloatNM.h
#ifndef FLOATNM_H
#define FLOATNM_H
#include <iomanip>
#include <iostream>
#include <math.h>
using std::cin;
using std::cout;
using std::endl;
class Float
{
friend Float
operator+(const Float& Left,
const Float& Right);
friend Float
operator*(const Float& Left,
const Float& Right);
friend Float
operator^(const Float& Left,
const Float& Right);
friend Float&
operator+=(Float& Left,
const Float& Right);
private:
float F;
public:
Float(float x) : F(x) {}
Float(): F(0) {}
// 定义 转换运算子 float
operator float() {return F;}
};
// 定义 operator+()
Float operator +
(const Float& Left, const Float& Right)
{return Float(Left.F + Right.F);}
// 定义 operator*()
Float operator *
(const Float& Left, const Float& Right)
{return Float(Left.F * Right.F);}
// 定义 operator^()
Float operator ^
(const Float& Left, const Float& Right)
{return Float(pow(Left.F, Right.F));}
// 定义 operator+=()
Float& operator +=
(Float& Left, const Float& Right)
{
Left.F += Right.F;
return Left;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -