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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:47:46+00:00 2026-05-29T11:47:46+00:00

Are there any drawbacks / disadvantages using the default constructor for default initialization for

  • 0

Are there any drawbacks / disadvantages using the default constructor for default initialization for primitive data types?

For example

class MyClass
{
public:
    MyClass(); 

private:
    int     miInt;
    double  mdDouble;
    bool    mbBool;
};

Using this constructor:

MyClass::MyClass() 
  : miInt(int())
  , mdDouble(double())
  , mbBool(bool())
{}

instead of this:

MyClass::MyClass() 
  : miInt(0)
  , mdDouble(0.0)
  , mbBool(false)
{}
  • 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-29T11:47:49+00:00Added an answer on May 29, 2026 at 11:47 am

    No, and the compiler will most probably generate the same code for both.

    With optimization off, the following code is generated:

    MyClass::MyClass() 
      : miInt(0)
      , mdDouble(0.0)
      , mbBool(false)
    {}
    012313A0  push        ebp  
    012313A1  mov         ebp,esp 
    012313A3  sub         esp,0CCh 
    012313A9  push        ebx  
    012313AA  push        esi  
    012313AB  push        edi  
    012313AC  push        ecx  
    012313AD  lea         edi,[ebp-0CCh] 
    012313B3  mov         ecx,33h 
    012313B8  mov         eax,0CCCCCCCCh 
    012313BD  rep stos    dword ptr es:[edi] 
    012313BF  pop         ecx  
    012313C0  mov         dword ptr [ebp-8],ecx 
    012313C3  mov         eax,dword ptr [this] 
    012313C6  mov         dword ptr [eax],0 
    012313CC  mov         eax,dword ptr [this] 
    012313CF  fldz             
    012313D1  fstp        qword ptr [eax+8] 
    012313D4  mov         eax,dword ptr [this] 
    012313D7  mov         byte ptr [eax+10h],0 
    012313DB  mov         eax,dword ptr [this] 
    012313DE  pop         edi  
    012313DF  pop         esi  
    012313E0  pop         ebx  
    012313E1  mov         esp,ebp 
    012313E3  pop         ebp  
    012313E4  ret           
    

    and

    MyClass::MyClass() 
      : miInt(int())
      , mdDouble(double())
      , mbBool(bool())
    {}
    001513A0  push        ebp  
    001513A1  mov         ebp,esp 
    001513A3  sub         esp,0CCh 
    001513A9  push        ebx  
    001513AA  push        esi  
    001513AB  push        edi  
    001513AC  push        ecx  
    001513AD  lea         edi,[ebp-0CCh] 
    001513B3  mov         ecx,33h 
    001513B8  mov         eax,0CCCCCCCCh 
    001513BD  rep stos    dword ptr es:[edi] 
    001513BF  pop         ecx  
    001513C0  mov         dword ptr [ebp-8],ecx 
    001513C3  mov         eax,dword ptr [this] 
    001513C6  mov         dword ptr [eax],0 
    001513CC  mov         eax,dword ptr [this] 
    001513CF  fldz             
    001513D1  fstp        qword ptr [eax+8] 
    001513D4  mov         eax,dword ptr [this] 
    001513D7  mov         byte ptr [eax+10h],0 
    001513DB  mov         eax,dword ptr [this] 
    001513DE  pop         edi  
    001513DF  pop         esi  
    001513E0  pop         ebx  
    001513E1  mov         esp,ebp 
    001513E3  pop         ebp  
    001513E4  ret     
    

    As you can see, it’s identical.

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

Sidebar

Related Questions

I want to know if there are any disadvantages/ drawbacks of using value objects
I'm using EPIC, but it seems to have some drawbacks. Are there any other
Are there are any drawbacks of using Heroku as the primary Git repo -
I am curious to know if there are any drawbacks or limitations of using
Is there any cost/drawback (apart from typing too much) to adorning a class with
Is there any way to check whether a file is locked without using a
Is there any efficiency difference in an explicit vs implicit inner join? For example:
Is there any disadvantage you face it when you using asp.net MVC? EDIT If
Are there any drawbacks to such a configuration?
I find myself using the Application class a lot to persist user data. These

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.