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,30 @@
#ifndef EXAMPLE34_CPOINT_H
#define EXAMPLE34_CPOINT_H
#include <iostream>
#include "Point.h"
class CPoint : public Point {
private:
int color;
public:
CPoint() : Point(), color(0) {
}
CPoint(int x1, int y1, int b) : Point(x1, y1), color(b) {
}
~CPoint() {
}
bool equal(Point& p) {
std::cout << "Method CPoint::equal(Point)" << std::endl;
return true;
}
bool equal(CPoint& cp) {
std::cout << "Method CPoint::equal(CPoint)" << std::endl;
if ( (this->x==cp.x) && (this->y == cp.y) && (this->color == cp.color))
return true;
else
return false;
}
};
#endif //EXAMPLE34_CPOINT_H

View File

@@ -0,0 +1,25 @@
#ifndef EXAMPLE34_POINT_H
#define EXAMPLE34_POINT_H
#include <iostream>
class Point {
protected:
int x, y;
public:
Point() : x(0), y(0) {
}
Point (int x, int y) : x(x), y(y) {
}
~Point() {
}
virtual bool equal(Point& p) {
std::cout << "Method Point::equal(Point)" << std::endl;
if ((this->x==p.x) && (this->y == p.y))
return true;
else
return false;
}
};
#endif //EXAMPLE34_POINT_H

View File

@@ -0,0 +1,29 @@
#include <iostream>
#include "Point.h"
#include "CPoint.h"
int main() {
Point* t1 = new Point(1,1);
Point* t2 = new CPoint(1,1,2);
CPoint* t3 = new CPoint(2,2,2);
std::cout << t1->equal(*t1) << std::endl;
std::cout << t1->equal(*t2) << std::endl;
std::cout << t1->equal(*t3) << std::endl;
std::cout << "-------------------" << std::endl;
/*
std::cout << t2->equal(*t1) << std::endl;
std::cout << t2->equal(*t2) << std::endl; // static type is checked for parameters
std::cout << t2->equal(*t3) << std::endl; // overloading is resolved during compile time
std::cout << "-------------------" << std::endl;
std::cout << t3->equal(*t1) << std::endl;
std::cout << t3->equal(*t2) << std::endl;
std::cout << t3->equal(*t3) << std::endl; // overloaded method hide overridden method
std::cout << "-------------------" << std::endl;
*/
delete t1;
delete t2;
delete t3;
return 0;
}