Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <exception>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- class Rectangle {
- int a;
- int b;
- public:
- void Print()
- {
- out << "A = " << a << ", B = " << b << '\n';
- }
- int Perimeter() {
- return 2 * (a + b);
- }
- int Area() {
- return a * b;
- }
- void setA(int value) {
- this->a = value;
- }
- void setB(int value) {
- this->b = value;
- }
- bool isSquare() {
- return (a == b);
- }
- const Rectangle operator++();
- const Rectangle operator--();
- };
- const Rectangle Rectangle::operator++()
- {
- this->a++;
- this->b++;
- return *this;
- }
- const Rectangle Rectangle::operator--()
- {
- this->a--;
- this->b--;
- return *this;
- }
- int main()
- {
- Rectangle a;
- a.setA(10);
- a.setB(15);
- a.Print();
- if (a.isSquare())
- out << "This is square\n";
- else
- out << "This isn't square\n";
- out << "Area = " << a.Area() << endl;
- out << "Perimeter = " << a.Perimeter() << endl;
- --a;
- a.Print();
- if (a.isSquare())
- out << "This is square\n";
- else
- out << "This isn't square\n";
- out << "Area = " << a.Area() << endl;
- out << "Perimeter = " << a.Perimeter() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement