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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:55:51+00:00 2026-05-30T03:55:51+00:00

Possible Duplicate: non-copyable objects and value initialization: g++ vs msvc Value-initializing an automatic object?

  • 0

Possible Duplicate:
non-copyable objects and value initialization: g++ vs msvc
Value-initializing an automatic object?

Consider the following statement:

It’s not really possible to value-initialize an automatic object.

Is this statement true? I see no problem in doing this:

int main()
{
    int i = int();
}
  • 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-30T03:55:52+00:00Added an answer on May 30, 2026 at 3:55 am

    The term value-initialization is defined in 8.5 [dcl.init] paragraph 16, 4th bullet:

    If the initializer is (), the object is value-initialized.

    That is, value-initialization of an automatic variable would look like this:

    int i();
    

    However, this is a declaration of a function called i returning an int. Thus, it is impossible to value-initialize an automatic. In your example, the temporary is value-initialized and the automatic variable is copy-initialized. You can verify that this indeed requires the copy constructor to be accessible using a test class which doesn’t have an accessible copy constructor:

    class noncopyable {
        noncopyable(noncopyable const&);
    public:
        noncopyable();
    };
    
    int main() {
        noncopyable i = noncopyable(); // ERROR: not copyable
    }
    

    SINCE C++11: int i{}; does the job (see also this).

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

Sidebar

Related Questions

Possible Duplicate: Error : get property of non-object I am new to codeigniter model,
Possible Duplicate: Why can you return from a non-void function without returning a value
Possible Duplicate: Why can you return from a non-void function without returning a value
Possible Duplicate: jQuery UI Slider - max value (not end of slider) I'm using
Possible Duplicate: Functional programming and non-functional programming I'm afraid Wikipedia did not bring me
Possible Duplicate: Why C# implements methods as non-virtual by default? I'm speaking primarily about
Possible Duplicate: How do you efficiently generate a list of K non-repeating integers between
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: Non-web SQL Injection Does someone know of a good example of a
Possible Duplicate: non static method cannot be referenced from static context hey i have

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.