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

  • Home
  • SEARCH
  • 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 7043961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:21:10+00:00 2026-05-28T02:21:10+00:00

Possible Duplicate: Why aren't static const floats allowed? Is there any reason why this

  • 0

Possible Duplicate:
Why aren't static const floats allowed?

Is there any reason why this is not possible in C++? It confuses me.

static const int A = 100; //no error
static const float B = 2.0f; //error, can't define this type in class definition.
  • 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-05-28T02:21:10+00:00Added an answer on May 28, 2026 at 2:21 am

    Static constants of integral types can be initialized inside a class definition. That doesn’t mean that the object actually exists, since you haven’t provided a definition yet, but because the compiler knows the value of the object, you can sometimes get away with it.

    That is, if you’re not attempting to take the address of the variable or pass it by reference, but only use its value, then you don’t need to provide a defintion at all, and the compiler simply substitutes the value wherever you use the variable.

    C++11 introduces the constexpr keyword which allows you to do the same for a much wider variety of types.

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

Sidebar

Related Questions

Possible Duplicate: .NET Controls: Why aren’t all calls thread-safe? This question is not about
Possible Duplicate: What's the difference between a URI and a URL? Is there any
Possible Duplicate: extension method requires class to be static Why aren't C# static class
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: Why global and static variables are initialized to their default values? What
Possible Duplicate: using mysql_close() Are mysql_close and pg_close required ? In some script there
Possible Duplicate: Is there a website where I can see which HTML 5 tags
Possible Duplicate: Why doesn't this code produce the desired result? I have the code:
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? I

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.