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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:08:57+00:00 2026-05-28T05:08:57+00:00

Possible Duplicate: What do the following phrases mean in C++: zero-, default- and value-initialization?

  • 0

Possible Duplicate:
What do the following phrases mean in C++: zero-, default- and value-initialization?

If I have a class for example:

class Info
{
   int x;
   int y;
};

which I used to created an object,

Info *p = new Info();

Does the brackets beside Info mean i’m value initializing it? How does it different from this, Info *p = new Info; ?

I know there is a question which differentiate between different meanings in new and old C++ language but I want to know the semantic difference between default and value initialization e.g. Does value initialization means initializing something to zero?

  • 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-28T05:08:58+00:00Added an answer on May 28, 2026 at 5:08 am

    A declared variable can be Zero Initialized, Value Initialized or Default Initialized.

    In your example:

    Info *p = new Info();    <------- Value Initialization
    Info *p = new Info;      <------- Default Initialization
    

    The C++03 Standard 8.5/5 aptly defines each:

    To zero-initialize an object of type T means:

    — if T is a scalar type (3.9), the object is set to the value of 0 (zero) converted to T;
    — if T is a non-union class type, each nonstatic data member and each base-class subobject
    is zero-initialized;
    — if T is a union type, the object’s first named data member is zero-initialized;
    — if T is an array type, each element is zero-initialized;
    — if T is a reference type, no initialization is performed.

    To default-initialize an object of type T means:
    — if T is a non-POD class type (clause 9), the default constructor for T is called (and the
    initialization is ill-formed if T has no accessible default constructor);
    — if T is an array type, each element is default-initialized;
    — otherwise, the object is zero-initialized.

    To value-initialize an object of type T means:
    — if T is a class type (clause 9) with a user-declared constructor (12.1), then the default
    constructor for T is called (and the initialization is ill-formed if T has no accessible
    default constructor);
    — if T is a non-union class type without a user-declared constructor, then every non-static
    data member and base-class component of T is value-initialized;
    — if T is an array type, then each element is value-initialized;
    — otherwise, the object is zero-initialized

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

Sidebar

Related Questions

Possible Duplicate: What do the following phrases mean in C++: zero-, default- and value-initialization?
Possible Duplicate: nullPointerException in multi column list I have following app which fetches data
Possible Duplicate: Collection initialization syntax in Visual Basic 2008? How is the following C#
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Multiple Inheritance in C# In the following example, I want the Shirt
Possible Duplicate: Invalid argument supplied for foreach() I have the following code: <? foreach($format
Possible Duplicate: NSNumber retain count issue Hello, I have the following code: NSNumber *number
Possible Duplicate: System of linear equations in C++? I have the following 2 systems
Possible Duplicate: What is the difference between String.Empty and “” Which of the following
Possible Duplicate: What does a colon following a C++ constructor name do? Class construction

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.