subject

C++. Hlp please! my last point((( Disassemble the program.
The main idea of ​​the template is to separate data and function (algorithm) and customize each of them separately, if necessary.

#include
using namespace std;

template
class Complex {
private:
T r, m; // x = Re + Im*i
public:
Complex(T nr = 0, T nm = 0) : r(nr), m(nm) { }
Complex operator+= (const Complex & c);
};

template
Complex Complex ::operator+= (const Complex & c) {

r += c. r;
m += c. m;
return *this;
}

template
Complex operator+ (const Complex & c1, const Complex & c2) {
Complex x = c1;
return x += c2;
}

int main(){

Complex<> a(0, 0), b(2, 2), c(7, -5);

Complex<> r1 = a + b + c;

Complex<> r2 = a;
r2 += b;
r2 += c;

return 0;
}

Exercise 1.1.
Try to create complex numbers based on the described template with real and imaginary parts represented by floating point numbers (float, double) and symbols (char).
Make any necessary changes to the implementation of the addition operators. Concatenation must occur when symbols are used.

Exercise 1.2.
Overload the input and output operations via the >> and << streams for the template.

Please note that the syntax for creating templates is quite flexible:
template class class_template_name {...};
After declaring a template, you can declare a class using this template:
class_template_name

Exercise 1.3.
Convert the template so that the data types r and m are different. And adapt the methods and functions developed in the program for this case.

Exercise 1.4.
Modify the program so that one of the template settings is the implementation of the operation for comparing complex numbers.
Those. so that you can choose not only data types, but also the logic for comparing two complex numbers.
Больше информации об этом исходном тексте

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen tool
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
Monica and her team have implemented is successfully in an organization. what factor leads to successful is implementation? good between different departments in an organization leads to successful is implementation.
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
question
Computers and Technology, 24.06.2019 00:20
The guy wire bd exerts on the telephone pole ac a force p directed along bd. knowing the p must have a 720-n component perpendicular to the pole ac, determine the magnitude of force p and its component along line ac.
Answers: 2
You know the right answer?
C++. Hlp please! my last point((( Disassemble the program.
The main idea of ​​the template is...
Questions
question
Mathematics, 04.04.2020 13:54
question
Mathematics, 04.04.2020 13:55
question
Mathematics, 04.04.2020 13:56