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 8916731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:19:04+00:00 2026-06-15T05:19:04+00:00

I have a polynomial implementation in a linked list and want to do std::ostream

  • 0

I have a polynomial implementation in a linked list and want to do std::ostream overloading operation but it gives my an error that no match for ‘operator<<’ in ‘std::cout << p5’

That’s my implementation but when I test it through cout << p5 I get the aforementioned error.

UPDATE:
header file:

struct term{
    double coef;
    unsigned deg;
    struct term * next;
};
class Polynomial {
public:
    constructors etc
    overloading functions
   friend ostream& operator << (ostream& out,const term& object);
}

then in other file poly.cpp i have:

 ostream & operator << (ostream& out, const Polynomial object){
        term* q = object.getptr();
        if (object.getptr() == NULL)
            out << "( )";
        else
            while(q != NULL)
            {
                out << q->coef << "x^" << q->deg << " ";
                q = q->next;
            }
        return out;
    }

in main.cpp
Polynomial p5, then added some terms and cout << p5 but I get errors.

  • 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-15T05:19:05+00:00Added an answer on June 15, 2026 at 5:19 am

    I think it’s your declarations which are causing the problem:

    friend ostream & operator << (ostream & out, const term & object);
    

    and

    ostream & operator << (ostream & out, const Polynomial & object);
    

    These don’t match. One is using a term object and the latter is using a Polynomial object. I’m assuming you want this function to use a term object because the function uses data memebers specific to the struct term. So change the latter to accept a term object:

    ostream & operator << (ostream & out, const term & object);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks like this: public class Polynomial { List<Term> term =
I have a linked list that is represented as struct term{ double coef; unsigned
I have a function specification that states it that should evaluate a polynomial function
I have a range of data that I have approximated using a polynomial of
Shortly: I have two linear linked lists which represent a polynomial. I have to
So I have a polynomial that looks like this: -4x^0 + x^1 + 4x^3
In main the list prints out using the insertion operator, but all that I
When we have a high degree linear polynomial that is used to fit a
I have a feature set [x1,x2....xm] Now I want to create polynomial feature set
I have a polynomial P and I would like to find y such that

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.