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,69 @@
#include <iostream>
#include "Complex.h"
Complex::Complex() : real(0), imag(0) {
}
Complex::Complex(double r, double i): real(r), imag(i) {
}
Complex::~Complex() {
}
void Complex::print() const {
std::cout << "(" << real << ", " << imag << "i)" << std::endl;
}
Complex Complex::plus(const Complex& snd) const {
Complex temp(real+snd.real, imag+snd.imag);
return temp;
}
Complex Complex::operator+(const Complex& snd) const {
Complex temp(real+snd.real, imag+snd.imag);
return temp;
}
/*
bool Complex::operator==(const Complex& snd) const {
if (this == &snd)
return true;
if ((this->real == snd.real) && (this->imag == snd.imag))
return true;
return false;
}
*/
/*
void Complex::operator=(const Complex& right) {
this->real = right.real;
this->imag = right.imag;
}
*/
/*
Complex& Complex::operator=(const Complex& right) {
this->real = right.real;
this->imag = right.imag;
return *this;
}
*/
/*
//prefix operator++
Complex& Complex::operator++() {
this->real++;
return *this;
}
//postfix operator++
Complex& Complex::operator++(int dummy) {
this->real += 10;
return *this;
}
*/
/*
// global function - a friend of class Complex
Complex operator+(double d, const Complex& snd) {
Complex temp(d+snd.real, 0+snd.imag);
return temp;
}
*/

View File

@@ -0,0 +1,23 @@
#ifndef EXAMPLE22_COMPLEX_H
#define EXAMPLE22_COMPLEX_H
class Complex {
//friend Complex operator+(double d, const Complex& snd);
private:
double real, imag;
public:
Complex();
Complex(double r, double i = 0);
~Complex();
void print() const;
Complex plus(const Complex& snd) const;
Complex operator+(const Complex& snd) const;
// more operators
//bool operator==(const Complex& snd) const;
//void operator=(const Complex& right);
//Complex& operator=(const Complex& right);
//Complex& operator++(); // prefix operator++
//Complex& operator++(int dummy); //postfix operator++
};
#endif //EXAMPLE22_COMPLEX_H

View File

@@ -0,0 +1,63 @@
#include <iostream>
#include "Complex.h"
int main() {
const Complex i(0,1);
Complex c1(1,1);
Complex c2, c3, c4;
i.plus(c1).print();
i.operator+(c1).print();
(i+c1).print();
/*
Complex* ptrc = new Complex(1,0);
ptrc->plus(c1).print();
ptrc->operator+(c1).print();
//(ptrc+c1).print();
(*ptrc+c1).print();
delete ptrc;
*/
/*
std::cout << "-----------------------" << std::endl;
c2=c1+i; //c2.operator=(c1.operator+(i));
c2.print();
*/
/*
std::cout << "------------------" << std::endl;
c2 = c1 + 1; //c2.operator=(c1.operator+(1));
c2.print();
//c3 = 2 + 1; //c3.operator=(3);
//c3.print();
//c4 = 1 + c1; // 1.operator+(c1) // operator+(1, c1)
//c4.print();
*/
/*
std::cout << "------------------" << std::endl;
c2.print();
c4 = c1 + 1;
c4.print();
if (c2 == c4)
std::cout << "Complex numbers are equal" << std::endl;
else
std::cout << "Complex numbers are not equal" << std::endl;
*/
/*
std::cout << "------------------" << std::endl;
Complex c5, c6;
c1.print();
c4 = c1 + 1;
c5 = c4;
c4.print();
c5.print();
//c6=c5=c4+c1;
//c5.print();
//c6.print();
*/
/*
std::cout << "------------------" << std::endl;
c1.print();
(++c1).print(); //c1.operator++()
(c1++).print(); //c1.operator++(int)
*/
return 0;
}