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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:20:57+00:00 2026-05-25T06:20:57+00:00

I have structure like this: struct Rz3DContourNode { float x; float y; float z;

  • 0

I have structure like this:

struct Rz3DContourNode {
  float x;
  float y;
  float z;
  float nx;
  float ny;
  float nz;
};

And I store elements in a STL vector as follows :

 std::vector < Rz3DContourNode >  nodes;

Now I want to change the nx,ny compoent of the nodes in the vector.I tried as follows:

*(&nodes[i].nx)=newNXValue;
*(&nodes[i].ny)=newNYValue;
*(&nodes[i].nz)=newNZValue;

This did not work.Is it because nodes[i] returns a copy of the object?

Is there any solution for this expect using pointers ?

I cannot use pointer (Rz3DContourNode*) , because I am using this vector in OpenGL as

glNormalPointer(GL_FLOAT,sizeof(Rz3DContourNode), &nodes[0].nx);

EDIT – I am sorry.I actually keep a QList and get the std::vector everytime.That was the reason

std::vector<Rz3DContourNode> nodeVector = nodes.toVector().toStdVector();
  • 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-25T06:20:58+00:00Added an answer on May 25, 2026 at 6:20 am

    It works on my compiler….
    Taking the address of the instance and then dereferencing it is the same as not doing it all.
    So you don’t need it. So replace this

    *(&nodes[i].nx)=newNXValue;
    

    with

    nodes[i].nx = newNXValue;
    

    Here is the code sample I tried:

    #include "stdafx.h"
    #include <stdio.h>
    #include <vector>
    
    struct Rz3DContourNode {
      float x;
      float y;
      float z;
      float nx;
      float ny;
      float nz;
    };
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        std::vector < Rz3DContourNode >  nodes;
        float newNXValue = 4545.4f;
        float newNYValue = 453.0f;
        float newNZValue = 34.0f;
    
        for (int i = 0; i < 3; i++)
        {
            Rz3DContourNode node = {1.0f,1.0f,1.0f,1.0f,1.0f,1.0f};
            nodes.push_back(node);
        }
    
        for (int i = 0; i < nodes.size(); i++)
        {
            nodes[i].nx = newNXValue;
            nodes[i].ny = newNYValue;
            nodes[i].nz = newNZValue;
        }
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a similar data structure like this: struct Data { std::string id; Blob
Let's say I have a first structure like this: typedef struct { int ivalue;
I have a large number of instances of a C structure like this: struct
I have structure for storing callback function like this: template<class T> struct CommandGlobal :
I have a structure something like this struct MyStructure :IFoo { } and a
I have a data structure like this: struct foo { int id; int route;
I have a structure like this. struct A { int someFun() const; int _value;
Say i have a data structure like this: type Foo struct { Bar []struct
I have a structure that more or less follows this pattern: struct sTruct {
I have a structure in C like this typedef struct SKT_SubHeader_s { U32 subLength;

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.