Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- class Complex {
- double Re_;
- double Im_;
- public:
- Complex(const double re, const double im = 0) : Re_(re), Im_(im) {}
- /*Complex operator+ (const Complex& other) const {
- return Complex(Re_ + other.Re_, Im_ + other.Im_);
- }*/
- const double& Re() const {
- return Re_;
- }
- double& Re() {
- return Re_;
- }
- double Im() const {
- return Im_;
- }
- friend Complex operator+ (const Complex& a, const Complex& b);
- friend void show(const Complex& a);
- Complex& operator++() {
- ++Re_;
- return *this;
- }
- Complex operator++ (int) {
- Complex temp = *this;
- ++Re_;
- return temp;
- }
- };
- void show(const Complex& a) {
- std::cout << a.Im_ << " " << a.Re_ << std::endl;
- }
- Complex operator- (const Complex& a, const Complex& b) {
- return Complex(a.Re() - b.Re(), a.Im() - b.Im());
- }
- Complex operator+ (const Complex& a, const Complex& b) {
- return Complex(a.Re_ + b.Re_, a.Im_ + b.Im_);
- }
- Complex operator+ (const Complex& a, int b) {
- return Complex(a.Re() + b, a.Im());
- }
- Complex operator+ (int a, const Complex& b) {
- return b + a;
- }
- struct Type {
- int& ref;
- Type(int& other) : ref(other) {}
- };
- struct Object {
- }
- int main() {
- Complex a(10, 10);
- Complex c = a + 5; // + Complex(double(5));
- Complex d = 5 + a; // CE
- Complex e = 5 - a; // OK Complex(double(5)) - a
- ++a;
- int value = 10;
- int q = ++value;
- int w = value++;
- //a++;
- for (Complex a(0); a.Re() < 10; a++) {
- }
- std::vector<Type> v;
- {
- int value = 10;
- int& a = value;
- v.push_back(Type(a));
- }
- v.front().ref = 10;
- Number a;
- (++a) = Number(10);
- a += 10;
- }
- /*
- a = [1,2,3]
- b = a
- b[2] = 3
- a[2] = 5
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement