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

The Archive Base Latest Questions

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

I got 17 integer constants that I’d like to have as private in my

  • 0

I got 17 integer constants that I’d like to have as private in my class. Is it really necessary to use initialization list?

I read somewhere that I can assign values to constants in the header file, but it doesn’t seem to work. I get this error message:

sorry, unimplemented: non-static data member initializers
  • 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-14T17:10:51+00:00Added an answer on June 14, 2026 at 5:10 pm

    Is it really necessary to use initialization list?

    In modern (2011-era) C++, no. In older versions of the language, yes.

    Your error message is apologising that your compiler doesn’t support the new initialisation syntax for non-static members yet. Assuming you’re using GCC (since I recognise that error from that compiler), then according to this page you’ll need to upgrade to at least version 4.7 for that feature.

    Alternatively, since they’re private and constant, you might consider moving them out of the class into a local namespace in the class’s implementation file. Of course, that will only work if you don’t need to access them from any inline member functions.

    Finally, if they have the same values for all instances of the class (which is likely, since they are const and you’re able initialise them independently of the constructor arguments), you could declare them static. Then they can be initialised in their declaration (although older compilers might only allow that if they have an integer type). However, if they are odr-used (roughly speaking, if you need to take a pointer or reference to them), then they will also need to be defined in exactly one source file.

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

Sidebar

Related Questions

I would like to create instances of a class containing a list that's empty
Say I've got an integer, 13941412, that I wish to separate into bytes (the
I got a Entity with a Integer @Entity(name=customer) public Customer { ... @Column private
I got a model like this: matrices ( matricesID integer; x integer; y integer;
I have the integer pixel I got from getRGB(x,y) , but I don't have
I've got m2m relationship like this: #main table CREATE TABLE products_product ( id integer
I've got an integer Coordinate Structure for a Hex grid, that I'm porting from
Unfortunately I've got a bug that I have been working on for 1 full
I've got a method that I'd like to test with JUnit/Mockito. The method takes
I've got an ArrayCollection that serves as a dataProvider for a list. The collection

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.