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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:55:26+00:00 2026-06-15T09:55:26+00:00

for google and stackoverflow search could not help me I have no choice but

  • 0

for google and stackoverflow search could not help me I have no choice but to ask you guys for help.

I would like to use an array of vectors – I know that this array will only have to contain two vectors. Thus

vector<double> testVect[1];

Now when I want to add an Element to the first vector contained in the array I use

testVect[0].push_back(0);

So far everything seems ok – unfortunately adding an Element to the first vector somehow also adds the same element (in this case the 0) to the second vector as well.

Could anybody tell me the reason for this kind of behaviour ? (please) – and perhaps a workaround.
Currently I have to use Visual Studio 6 (employer won’t install a new compiler – I am already riling up my coworkers 😀

  • 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-15T09:55:27+00:00Added an answer on June 15, 2026 at 9:55 am

    If you want two vectors, you should declare:

     vector<double> testVect[2];
    

    then use testVect[0] and testVect[1] in your code.

    And you should enable all warnings on your compiler.

    BTW, you could install a recent Linux distribution, with a recent GCC compiler (e.g. 4.7), and run it as g++ -Wall -g it would certainly have warned you if you statically accessed the testVect out of bounds, like it seems that you have had.

    Both GNU/Linux and GCC are free, so your manager could be happy.

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

Sidebar

Related Questions

I have gone through Google and Stack Overflow search, but nowhere I was able
I have been looking around ocn Google and Stackoverflow but haven't found what I
Ok guys, i've search in google and here in stackoverflow for this answer and
My google and stackoverflow search-fu have failed me, so I present to the community
I already did a search on Google and Stackoverflow, but I couldn't find any
I tried to search on Google or Stackoverflow but can't find such an operator.
I feel like an idiot for having to ask this question, but I have
First of all, I did some search and no answer on stackoverflow/google provided me
Well, StackOverFlow is such a good site, most of my google search results direct
I have searched around Google and StackOverflow trying to find a solution to this,

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.