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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:48:11+00:00 2026-05-28T02:48:11+00:00

I have trouble with pointers and references to doubles. I want to access elements

  • 0

I have trouble with pointers and references to doubles.

I want to access elements in QVector by names. The vector contains doubles:

QVector<double> properties;
properties.append(28.0);
properties.append(1.0);
properties.append(44.0);
properties.append(0.001);

Now I create pointers to doubles:

double* Amplitude;
double* Frequency;
double* PhaseDifference;
double* Stepsize;

These pointers should provide access to the elements of my vector:

Amplitude = &properties[0];
Frequency = &properties[1];
PhaseDifference = &properties[2];
Stepsize = &properties[3];

In my opinion dereferencing these pointers should give me the correct values, but it doesn’t. In this case I got zeros for the first two pointers and the third and fourth were correct.

I tried to use more entries in the vector and the result was that only the last two had the correct values. What is going wrong there?

I create and print the values in the constructor. Printing of the vector gives the right values!

Does anybody have an idea?

  • 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-28T02:48:12+00:00Added an answer on May 28, 2026 at 2:48 am

    Your named pointers are in fact iterators. Iterators can be invalidated. For example, whenever you resize the vector, or insert anything into them, etc. Look up the exact rules of iterator invalidation for your particular vector type, in this case, QVector and see if you’ve performed any of those iterator invalidating operations prior to printing. Incidentally, dereferencing an invalidated iterator may result in undefined behavior.

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

Sidebar

Related Questions

I have trouble comparing 2 double in Excel VBA suppose that I have the
I have trouble defining a trigger for a MySQL database. I want to change
I have some trouble using decltype for member function pointers: #include <iostream> #include <type_traits>
Have a homework assignment in which I'm supposed to create a vector of pointers
I have some trouble with pointers. I have a function that should return the
I am having trouble deleting my pointers that I have created. The program creates
I have trouble with the following piece of code. When I go through with
I have trouble using Perl grep() with a string that may contain chars that
I have trouble when designing classes like this class C1 { public: void foo();
I have trouble accessing filestream via SqlFileStream. Sql server and IIS7 are on different

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.