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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:19:44+00:00 2026-05-22T22:19:44+00:00

i got some problem with vector of vector. in my program, i have defined

  • 0

i got some problem with vector of vector. in my program, i have defined a dynamic memory for vector of vector and did the resize and push_back the elements.

vector<vector<double> > *planes = new vector<vector<double> >
planes->resize(s_list->size()); // size of another vector that i need to use
vector<int>::iterator s_no;
for(s_no=s_list->begin(), int i=0; s_no!=s_list->end(); s_no++, i++){){
                        //where i i the indices of planes

     //some codes for computing length, width

     planes->at(i).push_back(lenght);
     planes->at(i).push_back(width);
}

it works and i got the print of all values what i added. then, i changed new vector defining part as follows

vector<vector<double> > *planes = 
              new vector<vector<double> >(s_list->size(),vector<double>(2,0.0))

and removed the resize part. then, when i got the print out of vector of vector, i got 0 values for all. could you please rectify this issue.

  • 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-22T22:19:45+00:00Added an answer on May 22, 2026 at 10:19 pm

    Use at instead of push_back

     planes->at(i).at(0)=lenght;
     planes->at(i).at(1)=width;
    

    push_back() adds new items, therefore you end with with 4 items in each vector. You should use at() to modify the existing entries.

    Better still is to use a vector< pair<double,double> >, assuming you will always have two items.

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

Sidebar

Related Questions

I hope I got the relevant code in here. I have some problem when
i'm doing some code now and got some problem using restrict keyword. typedef int*
i dont't use java very often and now i got some Problem. I want
I've got some routing issues with MVC 2. Might be a simple problem, but
hey guys, I got some difficulty here. It is purely coding algorithm problem. Okay,
In Java I want to store elements in ascending order by size. Before insertion
Here is an analogy of my problem(a selector which has this selector together with
I am new to this forum and not well aware of protocols of this
I try to do something like this Javascript function as a parameter to another
i need to add textfield text to NSMutable string when end of the textfield

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.