blob: e3bec9aae90f3576c51f98066a1769421555961f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "complex.h"
#include <iostream>
Complex::Complex(double real, double imag) noexcept
: m_real(real), m_imag(imag)
{
}
Complex Complex::operator+(const Complex &other)
{
Complex result;
result.setReal(m_real + other.real());
result.setImaginary(m_imag + other.imag());
return result;
}
void Complex::show() const
{
std::cout << "(real: " << m_real << ", imag: " << m_imag << ")";
}
|