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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:04:06+00:00 2026-05-11T08:04:06+00:00

In the book I’m reading at the moment ( C++ Without Fear ) it

  • 0

In the book I’m reading at the moment (C++ Without Fear) it says that if you don’t declare a default constructor for a class, the compiler supplies one for you, which ‘zeroes out each data member’. I’ve experimented with this, and I’m not seeing any zeroing -out behaviour. I also can’t find anything that mentions this on Google. Is this just an error or a quirk of a specific compiler?

  • 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. 2026-05-11T08:04:07+00:00Added an answer on May 11, 2026 at 8:04 am

    If you do not define a constructor, the compiler will define a default constructor for you.

    Construction

    The implementation of this

    default constructor is:

    • default construct the base class (if the base class does not have a default constructor, this is a compilation failure)
    • default construct each member variable in the order of declaration. (If a member does not have a default constructor, this is a compilation failure).

    Note:
    The POD data (int,float,pointer, etc.) do not have an explicit constructor but the default action is to do nothing (in the vane of C++ philosophy; we do not want to pay for something unless we explicitly ask for it).

    Copy

    If no destructor/copy Constructor/Copy Assignment operator is defined the compiler builds one of those for you (so a class always has a destructor/Copy Constructor/Assignment Operator (unless you cheat and explicitly declare one but don’t define it)).
    The default implementation is:

    Destructor:

    • If user-defined destructor is defined, execute the code provided.
    • Call the destructor of each member in reverse order of declaration
    • Call the destructor of the base class.

    Copy Constructor:

    • Call the Base class Copy Constructor.
    • Call the copy constructor for each member variable in the order of declaration.

    Copy Assignment Operator:

    • Call the base class assignment operator
    • Call the copy assignment operator of each member variable in the order of declaration.
    • Return a reference to this.

    Note Copy Construction/Assignment operator of POD Data is just copying the data (Hence the shallow copy problem associated with RAW pointers).

    Move

    If no destructor/copy Constructor/Copy Assignment/Move Constructor/Move Assignment operator is defined the compiler builds the move operators for you one of those for you.
    The default implementation is:

    Implicitly-declared move constructor If no user-defined move constructors are provided for a class type (struct, class, or union), and all of the following is true:

    Move Constructor:

    • Call the Base class Copy Constructor.
    • Call the move constructor for each member variable in the order of declaration.

    Move Assignment Operator:

    • Call the base class assignment operator
    • Call the move assignment operator of each member variable in the order of declaration.
    • Return a reference to this.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The book I am reading says that after allocating an object I need to
The book I am reading says that SQL Server supports two kinds of character
One Book(Object Oriented Programming with C++ by E.Balagurusamy) says that const size = 10;
The book says The WPF Button class only adds two simple concepts on top
The book Professional Javascript by Zakas says that 1) IE uses event bubbling 2)
The book I'm reading says it does. I think it doesn't because it the
The book Pro Git says that the staging area is just a list, or
In book Head First C , it says that the computer does not allocate
the book says that reintegrated branch should not be used as it can't accept
A) Book I’m learning from says that if we handle Login.Authenticate event, then we

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.