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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:05:27+00:00 2026-05-11T06:05:27+00:00

Just started programming in C++. I’ve created a Point class, a std::list and an

  • 0

Just started programming in C++.

I’ve created a Point class, a std::list and an iterator like so:

class Point {  public:     int x, y;     Point(int x1, int y1)     {         x = x1;         y = y1;     } };  std::list <Point> pointList; std::list <Point>::iterator iter; 

I then push new points onto pointList.

Now, I’m needing to iterate through all the points in pointList, so I need to loop using the iterator. This is where I get screwed up.

for(iter = pointList.begin(); iter != pointList.end(); iter++) {     Point currentPoint = *iter;     glVertex2i(currentPoint.x, currentPoint.y); } 


Update

You guys were right, the problem isn’t in my iterating the list. It appears the problem is when I am attempting to push something on to the list.

Exact error:

mouse.cpp: In function void mouseHandler(int, int, int, int)': mouse.cpp:59: error: conversion fromPoint*’ to non-scalar type `Point’ requested

Those lines are:

 if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {     Point currentPoint = new Point(x, y);     pointList.push_front(currentPoint);  } 

What does it conversion between Point* to non-scalar type Point? I’m just trying to create new points and push them onto the list here.

  • 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. 2026-05-11T06:05:28+00:00Added an answer on May 11, 2026 at 6:05 am

    That should be a valid bit of code.

    #include <iostream> #include <list>  class Point {  public:     int x, y;     Point(int x1, int y1)     {         x = x1;         y = y1;     } };  int main() {     std::list<Point> points;      points.push_back(Point(0, 0));     points.push_back(Point(1, 1));     points.push_back(Point(2, 2));      std::list<Point>::iterator iter;      for(iter = points.begin(); iter != points.end(); ++iter)     {         Point test = *iter;         std::cout << test.x << ', ' << test.y << '; ';     }     std::cout << std::endl;      return 0; } 

    Using this code:

    jasons-macbook41:~ g++ test.cpp jasons-macbook41:~ ./a.out 0, 0; 1, 1; 2, 2;  jasons-macbook41:~  

    Although I wouldn’t create a temporary copy of the Point as your code does. I’d rewrite the loop like this:

    for(iter = points.begin(); iter != points.end(); ++iter) {     std::cout << iter->x << ', ' << iter->y << '; '; } 

    An iterator is syntactically similar to a pointer.

    EDIT: Given your new problem, drop the ‘new’ from the construction line. That’s creating a pointer to a Point, as opposed to a Point on the stack. This would be valid:

    Point* temp = new Point(0, 0); 

    Or this:

    Point temp = Point(0, 0); 

    And you’d be better off with the latter.

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

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Calling ToList or ToArray really is the best way to… May 11, 2026 at 8:43 pm
  • Editorial Team
    Editorial Team added an answer My experience is primarily with PHP, so you might have… May 11, 2026 at 8:43 pm
  • Editorial Team
    Editorial Team added an answer If you don't want to have it point to anything,… May 11, 2026 at 8:43 pm

Related Questions

Just started programming in C++. I've created a Point class, a std::list and an
I have just started to study computer sciences at my university where they teach
I've been programming in C,C++,C# and a few other languages for many years, mainly
Briefly: Does anyone know of a GUI for gdb that brings it on par
I am new to Windows and Visual Studio. I have a strong background in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.