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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:00, Leggett8152
What best describes a career pathway in a lodging career? a worker starts out as an amusement attendant, then becomes a recreation worker, and then becomes a gaming worker within five years. a worker starts out as a bell hop, then becomes a night clerk, and then becomes a hotel manager within five years. a worker starting out as a tour guide, then becomes a travel clerk, and then becomes a travel agent within five years. a worker starts out as a server, then becomes a food preparer, and then becomes a head chef within five years.
Answers: 1
image
Computers and Technology, 23.06.2019 12:10, jefersina16
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, kyleemarie2003
Companies that implement and apply an information system effectively can create
Answers: 1
image
Computers and Technology, 23.06.2019 18:40, brooklyn4932
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
You know the right answer?
C++. Hlp please! my last point((( Disassemble the program.
The main idea of ​​the template is...

Questions in other subjects:

Konu
Mathematics, 15.10.2019 11:10