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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:37:42+00:00 2026-06-13T18:37:42+00:00

I have the following setup: a class with a static member which is like:

  • 0

I have the following setup:

a class with a static member which is like:
static std::vector<int> m_Some[3];

The problem is, I cant m_Some[0].push_back(x) with it.
It triggers an error in <vector>‘s insert() and then in operator-.
But somehow the callstack is wrong for further actions so I cant see what’s real happening.

If I do m_Some[0].reserve(1); before push_back,
then I can make 1 push_back, but failed in the second push_back.

I have totally no idea why it can’t just push_back and has to reserve first…
And I event cant push_back more than the size I reserve.

I tried a local variable with same type of array, and it performs correctly with push_back.

I’m compiling using VS2008.

Anyone knows why? Thanks!

  • 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-13T18:37:43+00:00Added an answer on June 13, 2026 at 6:37 pm

    Are you calling push_back from a constructor of another static? In which case your vectors might not be constructed yet? Probably not, but there isn’t much to go on in the question. – J99 44 mins ago

    Maybe he’s experiencing a static initialization order fiasco. – akappa 43 mins ago

    @J99, yes I am calling it within a constructor of a global variable…! (declared in an .cpp) (but not static). I think that’s the problem, I’ll try to modify the code and see the result! – Marson Mao 33 mins ago

    @J99 and akappa: Exactly the problem is, the vector initialzation is after my calling in the constructor…I’ll try to solve that problem then. Thanks!! (How to mark the comment as the answer?!) – Marson Mao 27 mins ago

    @MarsonMao You cannot. Just answer your own question and mark it as accepted – akappa 8 mins ago

    Above are the answers!
    Thanks for the help 🙂

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

Sidebar

Related Questions

I want to have the following setup: abstract class Parent { public static String
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
If I have the following has_one setup: class Account has_one :user How can I
I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
I have the following class setup that trys mimicks a very basic stack. template
I have the following 3 classes class User { static hasMany = [coupons: Coupon]
I have the following setup: A templated class SpecialModel: template<typename A, typename B> class
Let's say we have the following setup: public class ClassA { public event EventHandler
I have the following class: public abstract class AbstractParent { static String method() {

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.