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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:04:06+00:00 2026-06-01T04:04:06+00:00

I have a large simulation written in C++. The main working unit for the

  • 0

I have a large simulation written in C++. The main working unit for the simulation is a class that represents neurons. To do its calculations, each instance of the neuron class needs access to the temperature. Each simulation uses tens of thousands of instances of the neuron class and the temperature is the same value for each neuron. For this reason, I would rather not have it be stored as regular member data, so each instance of the neuron class doesn’t have to take up memory storing its own copy. I would ideally store it as a static member variable (or, as a last resort, a global variable). However, I need the temperature to be determined at run-time as user input. Is there any simple way to give the neruon class access to this variable in the manner of static member data?

  • 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-01T04:04:06+00:00Added an answer on June 1, 2026 at 4:04 am

    Just because a variable is static, doesn’t mean that it also needs to be const. See the below code.

    #include <cassert>
    
    struct X {
        int member;
        static int static_var;
    };
    
    int X::static_var;
    
    int main() {
        X x;
        x.member = 1;
        x.static_var = 2;
    
        X y;
        y.member = 3;
        y.static_var = 4;
    
        X::static_var = 5;
    
        assert(x.static_var == y.static_var);
        assert(&x.static_var == &y.static_var);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simulation that reads large binary data files that we create (10s
We’ve found that the unit tests we’ve written for our C#/C++ code have really
I have large batches of XHTML files that are manually updated. During the review
I'm developing a website in PHP and I have large JS files that I
The simulation tool I have developed over the past couple of years, is written
I have a code that has a large number of malloc s and device-specific
I'm working on a simulation program that draws points and other primitives on top
I'm dealing with a large multi-national corp. I have a table (oldtir) that shows
The kind of simulation game that I have in mind is the kind where
I have written some code which performs a Monte Carlo simulation and produces curves

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.