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

  • Home
  • SEARCH
  • 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 6322145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:16:36+00:00 2026-05-24T16:16:36+00:00

I’ve been having some problems trying to implement an overloaded << operator function that

  • 0

I’ve been having some problems trying to implement an overloaded << operator function that can print out a std::list which is a member of one of my classes. The class looks like this:

class NURBScurve {
  vector<double> knotVector;
  int curveOrder;
  list<Point> points;
public:
  /* some member functions */
  friend ostream& operator<< (ostream& out, const NURBScurve& curve);
};

The key member variable I am interested in is the list of “Points” – this is another class that I have created which stores coordinates of a point along with associated member functions. When I try and implement the overloaded << operator function as:

ostream& operator<<( ostream &out, const NURBScurve &curve)
{
 out << "Control points: " << endl;
 list<Point>::iterator it;
 for (it = curve.points.begin(); it != curve.points.end(); it++)
    out << *it; 
 out << endl;
 return out;
}

I start to get problems. Specifically, I get the following error:
error:

no match for ‘operator=’ in ‘it = curve->NURBScurve::points. std::list<_Tp, _Alloc>::begin [with _Tp = Point, _Alloc = std::allocator<Point>]()’
/usr/include/c++/4.2.1/bits/stl_list.h:113: note: candidates are: std::_List_iterator<Point>& std::_List_iterator<Point>::operator=(const std::_List_iterator<Point>&)

I’m a bit stumped here, but I believe it has something to do with the list iterator I am using. I’m also not too confident with the notation of curve.points.begin().

If anyone can shed some light on the problem I would appreciate it. I’m at the point where I’ve been staring at the problem for too long!

  • 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-05-24T16:16:37+00:00Added an answer on May 24, 2026 at 4:16 pm

    curve is const-qualified, so curve.points is const-qualified and curve.points.begin() returns a std::list<Point>::const_iterator, not a std::list<Point>::iterator.

    Containers have two begin() and end() member functions: one pair are not const-qualified member functions and return iterators, the other pair are const-qualified and return const_iterators. This way you can iterate over a container that is not const and both read and modify the elements in it, but you can also iterate over a const container with read-only access.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.