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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:13:57+00:00 2026-05-23T11:13:57+00:00

If I have a structure with an array member, and I explicitly call the

  • 0

If I have a structure with an array member, and I explicitly call the default constructor of the array in the structure’s constructor, will the elements get default-constructed? (In the case of an integer array, this would mean getting zero-initialized).

struct S
{
    S() : array() {}

    int array[SIZE];
};

...

S s;
// is s.array zero-initialized?

A quick test with gcc suggests that this is the case, but I wanted to confirm that I can rely on this behaviour.

(I have noticed that if I don’t explicitly default-construct the array in the structure constructor, the array elements have random values.)

  • 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-23T11:13:58+00:00Added an answer on May 23, 2026 at 11:13 am

    Yes (highlighting mine):

    (C++03 8.5)

    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 baseclass component of T is value-initialized

    • if T is an array type, then each element is value-initialized;

    • otherwise, the object is zero-initialized

    …

    An object whose initializer is an empty set of parentheses, i.e., (), shall be value-initialized.

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

Sidebar

Related Questions

I have an array that is a member of a structure: $self->{myArray} = [value1,
I have an array structure that looks like this: Array ( [0] => Array
Lets say I have an array with a structure like this: $arr= Array( array(
I have an array of structures, sorted on a member of a structure, something
I need to have a fixed-size array of elements and to call on them
I have this string : 0=&task=rose&duration=1.25&user=15&1=&task=daisy&duration=0.75&user=25&2=&task=orchid&duration=1.15&user=7 I want this array structure : array( array(
I have a structure of html like this: <div id="triger1">some elements inside</div> <div id="triger2">some
I have the following array structure: Array ( [0] => Array ( [configuration_id] =>
Does VBA have dictionary structure? Like key<>value array?
I have this structure typedef struct fpinfo { unsigned long chunk_offset; unsigned long chunk_length;

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.