Reputation: 141
I'm trying to overload the operator >> and I want to read each character from an input but i get that error. Here is the code:
istream& operator>>(istream& input, Natural_Big_Number number)
{
int x;
input >> x;
number.set_nr_digits(x);
char c;
while ((c = input.get(c)))
{
}
}
Upvotes: 0
Views: 584
Reputation: 19751
You need to not specify a parameter to .get()
if you want it to return the character. https://en.cppreference.com/w/cpp/io/basic_istream/get
#include <iostream>
using namespace std;
istream& operator>>(istream& input, int number)
{
char c;
while ((c = input.get()))
{
}
}
If what you want is to check the boolean value of the stream for false
ness, then you would do what was mentioned in the comments, instead:
while (input.get(c))
which stores the character in c
then checks the bool
value of the returned input stream.
Upvotes: 1