帮忙改有理数程序 相当简单的程序 不要改复杂了

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:39:35
写的第一个程序 貌似相当残缺 初学者 嘿嘿 帮忙改一下
#include<iostream>
using namespace std;
class yls
{
public:
void set(int,int);
void plus(int,int);
void minus(int,int);
void multiply(int,int);
void divide(int,int);
private:
int fz;
int fm;
}

void yls::set(int a,int b)
{
cin>>a>>b;
a.getfz()=a*a.getfm();
b.getfz()=b*b.gerfm();
}

void yls::plus(int,int)
{
fm=a.getfm()*b.getfm();
fz=b.getfm()*a.getfz()+a.getfm()*b.getfz();
}

void yls::minus(int,int)
{
fm=a.getfm()*b.getfm();
fz=b.getfm()*a.getfz()-a.getfm()*b.getfz();
}

void yls::multiply(int,int)
{
fm=a.getfm()*b.getfm();
fz=a.getfz()*b.getfz();
}

void yls::divide(int,int)
{
fm=a.getfm()*b.getfz();
fz=a.getfz()*b.getfm();
}

int main()
{
yls p;
p.set();
p.plus();

getfm()和getfz()是什么函数啊??
你在头文件里加上:
#include <math.h>
试试看
还有在你的iostream后面加上“.h”在类的定义后面加上分号,可能是你的语法错误吧