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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:24:19+00:00 2026-05-24T22:24:19+00:00

I had trouble with initializing arrays of pointers. What I found out compiling with

  • 0

I had trouble with initializing arrays of pointers. What I found out compiling with gcc c++ (4.6.0) is:

MyClass** a = new MyClass*[100];

Does not always initalize the array of pointers. (most of the time it did give me an array of null pointers which confused me)

MyClass** a = new MyClass*[100]();

DOES initialize all the pointers in the array to 0 (null pointer).

The code I’m writing is meant to be be portable across Windows/Linux/Mac/BSD platforms. Is this a special feature of the gcc c++ compiler? or is it standard C++? Where in the standard does it says so?

  • 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-24T22:24:19+00:00Added an answer on May 24, 2026 at 10:24 pm

    This value-initialization is standard C++.

    The relevant standardeese is in C++98 and C++03 §5.3.4/15. In C++98 it was default-initialization, in C++03 and later it’s value initialization. For your pointers they both reduce to zero-initialization.

    C++03 §5.3.4/15:

    – If the new-initializer is of the form (), the item is value-initialized (8.5);

    In C++0x that paragraph instead refers to “the initialization rules of 8.5 for direct-initialization”, where in N3290 (the FDIS) you find about the same wording in §8.5/16.

    Cheers & hth.,

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

Sidebar

Related Questions

I've always had trouble with retrieving values in API-returned arrays, usually because they are
For some reason I've always had trouble remembering the backwards/forwards compatibility guarantees made by
I had trouble searching for potential duplicates because I'm not sure what the correct
I had trouble coming up with a title for this question because I'm not
I always had trouble with estimating cost/price of finished software (or programming work), so
I found lots of answers regarding AJAX calls, but I had trouble finding an
I'm not sure if anyone else has had trouble with this. I'm trying to
I had trouble finding a function that does exactly what I am looking for.
I'm new to PHP, having trouble when I move a class definition out of
I've had trouble finding a clear, concise laymans definition of a class. Usually, they

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.