Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:51:31+00:00 2026-06-14T20:51:31+00:00

Here is the code and I don’t seem to find what’s wrong with it;

  • 0

Here is the code and I don’t seem to find what’s wrong with it; I need to overload the << and >> operators, but I get the following error:

Use of overloaded operator ‘>>’ is ambiguous (with operand types ‘istream’ (aka ‘basic_istream’) and ‘MyIncreEx’)

I can’t see what’s really ambiguous about it:

class MyIncreEx;

istream& operator>>(istream& is, MyIncreEx& s);
ostream& operator<<(ostream &os, MyIncreEx& s);
MyIncreEx operator++(MyIncreEx& d, int dummy);
MyIncreEx operator++(MyIncreEx& d);

class MyIncreEx
{
    friend istream& operator>>(istream& is, MyIncreEx s);
    friend ostream& operator<<(ostream& os, MyIncreEx s);
    friend MyIncreEx operator++(MyIncreEx& d, int dummy);
    friend MyIncreEx operator++(MyIncreEx& d); 

public:
    int num1 = 0, num2 = 0, num3 = 0;
};

istream& operator>>(istream& is, MyIncreEx& s)
{
    is >> s.num1;
    is >> s.num2;
    is >> s.num3;
    return is;
};

ostream& operator<<(ostream &os, MyIncreEx& s)
{
    os << "(" << s.num1 <<"," <<s.num2 << "," << s.num3 <<")"<< endl;
    return os;
};

MyIncreEx operator++(MyIncreEx& d)              
{
    d.num1++;
    d.num2++;
    d.num3++;
    return d;
};

MyIncreEx operator++(MyIncreEx& d, int dummy) 
{
    d.num1++;
    d.num2++;
    d.num3++;
    return d;
};

int main()
{
    MyIncreEx obj;

    cout << "please enter three numbers: ";
    cin  >> obj;
    
    cout << "The original value are: " << obj << endl;
    obj++;
    
    cout << "The new values after obj++ are: " <<  obj << endl;
    ++obj;
    
    cout << "The new values after ++obj are: " << obj << endl;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:51:32+00:00Added an answer on June 14, 2026 at 8:51 pm

    You declared two different versions of the output operators:

    istream& operator>>(istream& is, MyIncreEx& s);
    ostream& operator<<(ostream &os, MyIncreEx& s);
    
    class MyIncreEx
    {
        friend istream& operator>>(istream& is, MyIncreEx s);
        friend ostream& operator<<(ostream& os, MyIncreEx s);
        ...
    };
    

    The friend operators have a different and conflicting signature. You probably wanted to declare them as

        friend istream& operator>>(istream& is, MyIncreEx& s);
        friend ostream& operator<<(ostream& os, MyIncreEx const& s);
    

    (assuming you also fix the output operator to work with MyIncreEx const& rather than MyIncreEx&).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All my code is here,quite simple,and I don't konw where it goes wrong. Person
I don't know why I'm facing that error ! Here is my code snippet
I'm trying to solve the problem here but I don't know why my code
My code is here $(a[href=$.jqURL.url()]).hide(); $.jqURL.url() return current page url. But this code don't
I saw an article here: http://code.lancepollard.com/automatically-publish-posts-to-stumbleupon-with-ruby I don't know Ruby, but the following lines
Here my code rendering pdf is ok .But I don't want render directly save
Here is some code I don't understand, but I know it opens the link
Here is code from MSDN . I don't understand why the work isn't just
Here's the code, I don't quite understand, how does it work. Could anyone tell,
I am new to xml and android programming.Here is my xml code... I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.