SoraMarch
SoraMarch

Reputation: 1

C++ Override >> operator

I am writing a program where an arbitrarily large number is represented by a doubly linked list where a node in this list represents one digit of the large number.

As part of the problem, I need to override the '>>' operator so that when I type in a large number, the program takes the number and creates a big_number class using that number. (big_number class is the doubly linked list representing a large number.)

My Override:

istream& >> operator(istream& in, big_number& n)
{
    //Code I need to write
    return in;
}

Upvotes: 0

Views: 103

Answers (1)

Cheers and hth. - Alf
Cheers and hth. - Alf

Reputation: 145279

This line:

istream& >> operator(istream& in, big_number& n)

should be either

istream& operator>>( istream& in, big_number& n )

or

auto operator>>( istream& in, big_number& n )
    -> istream&

In your later SO postings, please include also your build command and error messages.


In passing, regarding terminology, this is an overload, not an override. The latter is what you have when you override a base class’ virtual member function.

Upvotes: 2

Related Questions