value, b;
public:
Notebook(int c)
{
b = c;
}
void showdata1()
{
cout << "1)" << b << endl;
}
void showdata2()
{
cout << "2) " << b << endl;
}
void showdata3()
{
cout << "3)" << b << endl;
}
void showdata4()
{
cout << "4)" << b << endl;
}
void showdata5()
{
cout << "5)" << b << '\n' << endl;
}
Notebook(int i) : value(i)
{}
friend const Notebook operator+(const Notebook& left, const Notebook& right);
friend Notebook operator-(Notebook& left, const Notebook& right);
friend Notebook operator*(const Notebook& left, const Notebook& right);
friend Notebook operator/(const Notebook& left, const Notebook& right);
const Notebook operator+(const Notebook& right)
{
return this->value + right.value;
}
const Notebook& operator-(const Notebook& right)
{
return this->value - right.value;
}
const Notebook operator*(const Notebook& right)
{
return this->value * right.value;
}
const Notebook operator/(const Notebook& right)
{
return this->value / right.value;
}
};
int main()
{
setlocale(LC_ALL, "russian");
Notebook s1(60), s2(64), s3(46), s4(18), s5(18);
int n1 = 2, n2 = -2, n3 = 3, n4 = 2, n5 = 2;
s1.showdata1();
s2.showdata2();
s3.showdata3();
s4.showdata4();
s5.showdata5();
Notebook b1 = s1 + n1;
b1.showdata1();
Notebook b2 = s2 + n2;
b2.showdata2();
Notebook b3 = s3 - n3;
b3.showdata3();
Notebook b4 = s4 * n4;
b4.showdata4();
Notebook b5 = s5 / n5;
b5.showdata5();
return 0;
}
Почему не работает с s1-n1?это значения просто
Почему не работает с s1-n1? здесь нет этого s1-n1
Так если у тебя b3 = s3 - n3 работает, то и проблем не должно быть
Обсуждают сегодня