Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Новый участник


Сообщения: 15
Благодарности: 0

Профиль | Отправить PM | Цитировать


Помогите исправить ошибки,пожалуста.Прога должна описывать дробь и производить сложение.вычитание.умножение.деление дробей.Вот прога:
Код: Выделить весь код
 
#include<iostream.h>
void main()
 
struct rational
{
	rational(int p=1, int k=1)
		: a(p), b(p) {}
	int a,b;
cin>>a"\n";
cin>>b"\n";
	rational& operator+(const rational& s)
	{
		int k=b*s.b;
		a=a*s.b+s.a*b;
		b=k;
cout<<a<<"\n";
		return *this;
	}
	rational& operator-(const rational& s)
{
int k=b*s.b;
a=a*s.b-s.a*b;
b=k;
cout<<a<<"\n"
return &this;
}
	rational& operator\(const rational& s)
{
int k=b*s.b;
a=(a*s.b)\(s.a*b);
b=k;
cout<<a<<"\n"
return &this;
}
	rational& operator * (const rational& s)
{
int k=b*s.b;
a=(a*s.b)*(s.a*b);
b=k;
cout<<a<<"\n";
return &this;
}
};

Отправлено: 10:02, 03-02-2006 | #5