consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#include <iostream>
#include <cmath>
#include "Point.h"
Point::Point() : x(0), y(0) {
}
Point::Point(const Point& t) : x(t.x), y(t.y) {
}
Point::Point(int xy) : x(xy), y(xy) {
}
Point::Point(int xx, int yy) {
//Point::Point(int x, int y) {
//Point::Point(int x, int y) : x(x), y(y) {
x=xx;
y=yy;
//this->x=x;
//this->y=y;
}
Point::~Point() {
}
int Point::getX() {
return x;
}
int Point::getY() {
return y;
}
void Point::print() {
std::cout << "(" << x << ", " << y << ") " << std::endl;
}
double Point::distance(Point t) {
return std::sqrt((double)(x - t.x)*(x - t.x)+(y - t.y)*(y - t.y));
}

View File

@@ -0,0 +1,20 @@
#ifndef EXAMPLE02_POINT_H
#define EXAMPLE02_POINT_H
class Point {
private:
int x, y;
public:
Point(); // default constructor is needed when other than copy constructor is defined
Point(const Point& t); // copy constructor
Point(int xy); // conversion constructor
Point(int x, int y); // other constructor
~Point(); // destructor
// methods
int getX();
int getY();
void print();
double distance(Point t);
};
#endif //EXAMPLE02_POINT_H

View File

@@ -0,0 +1,39 @@
#include <iostream>
#include "Point.h"
int main() {
Point a;
Point b(5);
Point c(4,3);
Point d(c);
a.print();
b.print();
c.print();
d.print();
std::cout << a.distance(c) << std::endl;
//std::cout << a.distance(5) << std::endl;
/*
Point arr[3]; // default constructor is called
for (int i=0; i < 3; i++)
arr[i].print();
*/
/*
std::cout << "-----Dynamic allocation-----" << std::endl;
Point* e = new Point();
Point* f = new Point(5);
Point* g = new Point(2,3);
Point* h = new Point(*g);
//e.print();
//*e.print();
//(*e).print();
e->print();
f->print();
g->print();
h->print();
delete e;
delete f;
delete g;
delete h;
*/
return 0;
}