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

  • Home
  • SEARCH
  • 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 8830901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:11:45+00:00 2026-06-14T08:11:45+00:00

I was thinking today while reading about the default constructor of classes in C++

  • 0

I was thinking today while reading about the default constructor of classes in C++ and let’s say we have this code of the class SortedArray:

class SortedArray
{

private:
    struct arrayCell
    {
        int pageID;                
        int totalNeighbors;   
    };
};

We assign an array of pointers pointing to objects of this class and then we initialize the pointers using the default constructor. What will happen? Will memory be stored for the structs? And if it is what will the int’s be initialized to? Thanks.

  • 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-14T08:11:46+00:00Added an answer on June 14, 2026 at 8:11 am

    OLD ANSWER: Im pretty sure that memory is created for that element, if you compile and run it there is no segmentation fault when accessing that memory. The ints will be set to the default value of 0.

    Default constructor information can be found here.

    EDIT: The above answer is incorrect. The code will not provide memory for the integer elements because the struct is defined but no object using the struct will be created unless you create one manually in which case the memory for those integers will be created.

    As for the value of the created integers:

    They will not be initialised to anything that makes sense they will simply contain what was in the memory before they were created.

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

Sidebar

Related Questions

today i was thinking about tell! don't ask! and experimenting with this code. interfaces:
I was thinking about this today and I realized I don't have a clear
Today I was thinking about declaring this: private delegate double ChangeListAction(string param1, int number);
I use namedtuple classes a lot. I have been thinking today if there is
I'm thinking today at the following scenario: I have two classes A and B.
Came by a curious case today, that got me thinking about how the object
Thinking about avoiding code replication, I got a question that catches me every time
Im thinking this is correct, but probably WAY off. I have a string formatted
Been thinking about this for hours now. Im building a simple slideshow application, where
I was thinking today about the try/catch blocks existent in another languages. Googled for

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.