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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:20:49+00:00 2026-06-11T23:20:49+00:00

EDIT: Changed my question to something more meaningful If i have a class: class

  • 0

EDIT: Changed my question to something more meaningful

If i have a class:

class A{
public:
     int nr;
     int *a;

     A();
};

A::A(): nr(0), a = new int[10]{}

This chrases, but if I have

 A::A(): nr(0) {a = new int[10];}

It works. Please explain this behavior to me.

  • 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-06-11T23:20:50+00:00Added an answer on June 11, 2026 at 11:20 pm

    nr(0) is an initializer for the data member nr.

    {a = new T[10]; } is a constructor body that assigns a value to the data member a after the initialization in the initializer list has been performed.

    {} is an empty constructor body, it means the constructor does nothing (other than initialize nr, of course, since that’s in the initializer list).

    a = new int[10] in between the initializer list and the constructor body is nonsense, the syntax of the language doesn’t permit it. It shouldn’t compile, but if you’ve found a compiler that accepts it and then it crashes, you’ll have to look at that compiler’s documentation for an explanation.

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

Sidebar

Related Questions

EDIT: I have changed the question as it was too localized and gained negative
--EDIT-- I believe this is a valid question that may have multiple answers (as
I have a simple question. I have a model that looks like this: public
I found this question , which has an answer, but facebook changed the token
Edit: Just wanted to make the question I have more clear. I pretty much
Consider the following class: class Something : ISomething { public void DoesSomething(int x) {
[EDIT] This question is how do I do atomic changes to entity beans with
This question has no practical issues associated with it, it is more a matter
Edit: I've changed my question and code to clarify my question better I've got
Just to give a little more context to the question, I have a web

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.