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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:29:32+00:00 2026-05-27T20:29:32+00:00

Consider the case of class which does not have a destructor and constructor explicitly

  • 0

Consider the case of class which does not have a destructor and constructor explicitly declared by the developer. I understand that a destructor for a class will be implicitly declared in this case. Then is it true that the destructor is implicitly defined, only when an object of the class is about to be destroyed?

Is the behavior of constructor also the same as above. Is it implicitly defined only when an object of the class is created?

EDIT

class A {
  public:

};
int main() {

}

In the above code, ~A() will be implicitly declared. My question is whether it true that the definition for the destructor will be made implicitly, only if an object of the class is instantiated like

class A {
      public:

    };
    int main() {
      A a;
    }

Or is it implicitly defined, even if object instantiation is not done ?

  • 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-27T20:29:33+00:00Added an answer on May 27, 2026 at 8:29 pm

    Yes, implicitly declared default constructors and destructors are implicitly defined when they are used to create or destroy instances of the object. In the words of the standard (C++11):

    12.1/6: A default constructor that is defaulted and not defined as deleted is implicitly defined when it is odr-used
    (3.2) to create an object of its class type (1.8) or when it is explicitly defaulted after its first declaration.

    12.4/5: A destructor that is defaulted and not defined as deleted is implicitly defined when it is odr-used (3.2) to
    destroy an object of its class type (3.7) or when it is explicitly defaulted after its first declaration.

    So they are defined in your second code snippet, which creates and destroys an object of type A, but not in the first, which doesn’t.

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

Sidebar

Related Questions

Consider a hypothetical method of an object that does stuff for you: public class
Consider: class MyClass<T> where T : class { } In that case, the where
Consider the following case: public class A { public A() { b = new
Please consider the following simple use case: public class Foo { public virtual int
EDIT: I missed a crucial point: .NET 2.0 Consider the case where I have
Consider a class that is supposed to make parameter suggestion, given some clues, and
I have a class which looks something like this: public class Test { private
We have a web application (quite a heavy-weight one) that does a whole bundle
I have a WPF ListView inside StackPanel, with Height=Auto. It's great that it does
I have a WPF ListView inside StackPanel, with Height=Auto. It's great that it does

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.