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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:07:18+00:00 2026-06-02T09:07:18+00:00

I have a point3 struct that takes 3 floats x, y, z (3-D space

  • 0

I have a point3 struct that takes 3 floats x, y, z (3-D space coordinates).

I’m trying to write a function that translates the x, y, z values of each element in a list of points.

I’m new to C++ so I don’t think I wrote the iterator correctly, can anyone help clarify how to iterate down a list and modify components of each element in the list?

I looked at this post C++ How to loop through a list of structs and access their properties and thought this answered my problem, but the solution didn’t work.

Here is my code:

//Translates the face by dx, dy, dz coordinates
list<point3> translateFace(list<point3> lop, float dx, float dy, float dz)
{
    list<point3>::iterator iter;

    for (iter = lop.begin() ; iter != lop.end(); iter++){
        iter->x - dx;
        iter->y - dy;
        iter->z - dz;
    }
   return lop;
}

I also tried the solution suggested in the link above, still didn’t work. Should return lop be inside or outside the for loop? Should I be returning something other than lop?

for (iter = lop.begin() ; iter != lop.end(); iter++){
    (*iter).x - dx;
    (*iter).y - dy;
    (*iter).z - dz;
    }
return lop;
  • 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-02T09:07:19+00:00Added an answer on June 2, 2026 at 9:07 am

    It appears to me that you’re not actually storing the results of your calculation:

    for (iter = lop.begin() ; iter != lop.end(); iter++){
        iter->x - dx;
        iter->y - dy;
        iter->z - dz;
    }
    

    Try this:

    for (iter = lop.begin() ; iter != lop.end(); iter++){
        iter->x -= dx;
        iter->y -= dy;
        iter->z -= dz;
    }
    

    I would hope most compilers would throw a warning about an unused calculation like this — turn up the warning level on your compiler if you can.

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

Sidebar

Related Questions

I have an array of structs. The struct has two function pointers. Each element
I have to write a program for my C programming class that takes a
I have a function pointer inside a struct that gets dynamically set at runtime
I have a struct that contains a float var. I am trying to read
i have two points in 3D space which have X-coordinates with different signum. so
Hi I created a function that takes in an accepted sockFD as input and
Hi I am trying to make a simple server that takes in an IP
In my C# application, I have a large struct (176 bytes) that is passed
I have a C function that does some pixel manipulation on a raw 2D
I am using a library that has a function that takes an array of

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.