Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication7.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- class GCords {
- private:
- double width;
- double length;
- public:
- GCords () {}
- GCords(double g_width, double g_length) {
- width = g_width;
- length = g_length;
- }
- GCords(const GCords& obj) {
- this->width = obj.width;
- this->length = obj.length;
- }
- double GetWidth() { return this->width; }
- double GetLength() { return this->length; }
- void SetWidth(double width) { this->width = width; }
- void SetLength(double length) { this->length = length; }
- double Distance() {
- return width * width + length * length;
- }
- GCords operator+(const GCords obj) {
- GCords cord1;
- cord1.SetWidth(this->width + obj.width);
- cord1.SetLength(this->length + obj.length);
- return cord1;
- }
- bool operator==(const GCords obj) {
- if (this->length == obj.length && this->width == obj.width)
- {
- return true;
- }
- return false;
- }
- bool operator<(const GCords obj) {
- if (this->length < obj.length && this->width < obj.width)
- {
- return true;
- }
- return false;
- }
- friend istream& operator>>(istream& input, GCords& obj) {
- input >> obj.length;
- input >> obj.width;
- return input;
- }
- friend ostream& operator<< (ostream& output, GCords& obj) {
- output << obj.length;
- output << obj.width;
- return output;
- }
- };
- int main()
- {
- GCords tochka1(-10.0,6.0);
- GCords tochka2(-6.0, 10.0);
- GCords tochka3 = tochka1 + tochka2;
- cout << tochka3.Distance();
- std::cout << "Hello World!\n";
- }
- // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
- // Debug program: F5 or Debug > Start Debugging menu
- // Tips for Getting Started:
- // 1. Use the Solution Explorer window to add/manage files
- // 2. Use the Team Explorer window to connect to source control
- // 3. Use the Output window to see build output and other messages
- // 4. Use the Error List window to view errors
- // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
- // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement