This is my pt2 of my previously posted question which idk if its gonna be answered or not after I edited since it was already considered 'answered' i think.
Ok so I'm now trying for output a + bi :
std::ostream& operator<< (std::ostream& out, complex const& c) {
return out << c.getReal() << "+" << c.getImag() << "i";
}
and for input:
std::istream& operator>> (std::istream& in, complex& c) {
double h, j;
if (in >> h >> "+" >> j >> "i") {
c.set(h, j);
}
return in;
}
However I get the following error when I compile:
This is for line 181 of my complex.cpp file(class complex implementation file) where if (in >> h >> "+" >> j >> "i") {
is located of the above function definition is located:
binary '>>': no operator found which takes a right-hand operand of type 'const char [2]' (or there is no acceptable conversion)
the following are all for line 45(Note each error is separate,total of 7 for this line) of my complex.h file where friend std::istream &operator>> (std::istream &in, complex& c);
protoype is located.
'istream':is not a member of 'std'
syntax error missing ';' before '&'
'istream':'friend' not permitted on data declarations
missing type specifier-int assumed. Note:C++ does not support default-int
unexpected token(s) preceding';'
namespace "std" has no member "istream"
namespace "std" has no member "istream"
the following are for line 46 of my complex.h file where
friend std::ostream &operator<<(std::ostream &out, complex c);
is located
'ostream': is not a member of 'std'
syntax error: missing ';' before '&'
'ostream':'friend' not permitted on data declarations
missing type specifier -int assumed.Note: C++ does not support default-int
unexpected token(s) preceding ';'
namespace "std" has no member "ostream"
namespace "std" has no member "ostream"
I noticed both are the same type of errors. Note I have
#include<iostream>
using namespace std;
both on the complex.cpp file and the main.cpp file