I got this assignment where I have linked list with Complex numbers and the task is to imput and print these numbers with help of linked list. Several years ago i studied the basics of complex numbers but the assignment is really confusing for me now and I don’t know where to start, the only given information is the one above and the following .h file:
#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
struct Complex
{
int real, imag;
};
void read(Complex &, std::istream &);
void print(const Complex &, std::ostream & os=std::cout);
bool operator<(const Complex & lhs, const Complex & rhs);
bool operator>(const Complex & lhs, const Complex & rhs);
bool operator==(const Complex & lhs, const Complex & rhs);
#endif
I would be rally thankful for some initial guidance with this assignment, what should the print and read functons contain (except the given arguments) in order to use?? bool operators above? I googled for couple of hours but could not find any good relevance between complex numbers tutorials and my task, furthermore i have deadline for this and contacting my teachers with questions about this will take days.
The print function should display the number on the indicated output stream. Conventionally, complex numbers are displayed like this:
1+2ior this:(1+2i)or even this:(1,2). You might accomplish this through operator chaining:The equality check should return true if both components of
lhsare equal to their counterparts inrhs:The details of
read,operator<andoperator>will vary according to your exact assignment. Re-read your assignment, paying close attention to any definition of what those functions are required to do.