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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:50:10+00:00 2026-06-11T17:50:10+00:00

I am actually not really aware if you can declare a class and then

  • 0

I am actually not really aware if you can declare a class and then use a static instance it among several objects of the same class. More specifically:

class State {
    public:
        State();
        static CustomNumberDist normal_dist;
    private:
        int id;   
};

So every instance of State should contain the same instance of CustomNumberDist. I compiles but I am wondering if it is valid or I may run into problems later on.

  • 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-11T17:50:11+00:00Added an answer on June 11, 2026 at 5:50 pm

    The declaration (header file i.e. .h) that you have given is perfectly valid.

    However in the definition (.cpp file) you need

    State::CustomNumberDist normal_dist;
    

    As memory will be required for the static object when you get to the linking stage.

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

Sidebar

Related Questions

Actually, iPhone OS has an resolution independent measurement for view sizes. It's not really
Does java has library exception class which means actually not an error, but good
I am trying to use the timed_wait from boost. Now I am actually not
Actually Datalist not contain allowpaging property. so how can i set paging in datalist.
Ok actually im not really sure whether the last string in a url is
I'm new to php world (actually not so much, but pretty much). I make
I read that Python does not actually support 2D arrays but rather an array
As I do not trust many benchmarks out there, because they are not actually
For some reason, this code does not actually draw my bitmap file... or show
This deals with WordPress plugin development. Even if a user has not actually signed

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.