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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:30:29+00:00 2026-06-17T00:30:29+00:00

Should destructior be declared/implemented in pointerless class? Is there any advantage of having/not having

  • 0

Should destructior be declared/implemented in pointerless class?
Is there any advantage of having/not having it ?

What I men is:

class Point
{
public: 
    int X, Y;
    Point(int x, int y);
    //~Point(void);       //should I uncoment it and implement empty destructor ?
}
  • 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-17T00:30:31+00:00Added an answer on June 17, 2026 at 12:30 am

    Should destructior be declared/implemented in pointerless class?

    No need[conditions apply]. the compiler will generate one for you.
    You should provide one only if you want to perform something specific, which the compiler will not.
    For example:

    • Resource management(Memory managemnt, FIle handling),
    • Logging,
    • Close network connections,
    • In short custom functionality which needs to execute each time a object is destroyed

    In general the thumb rule is:
    “If you need to provide a copy constructor or a copy assignment operator then you most probably also need to provide your own destructor.”
    Popularly, this rule is known as the Rule of Three.


    [conditions apply] If your class is meant to act as an Base class for Inheritance and your implementation will require calling delete on a Base class pointer pointing to a derived class object then you need to provide a destructor and mark it as virtual in Base class, failure to do so will result in Undefined Behavior.


    Is there any advantage of having/not having it?

    None, since the compiler does the same there is no need to do the extra typing.

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

Sidebar

Related Questions

As I know, any class that is designated to have subclasses should be declared
Should I merge those tables into one table? Is there any tricky alternative? Table
class Equipment { std::vector<Armor*> vEquip; Weapon* mainWeapon; int totalDefense; int totalAttack; public: unsigned int
Guideline #4 link text , states: A base class destructor should be either public
Should timestamps always use UTC (as in 2012-06-14T10:32:11+00:00 ) and not local time (as
Should I include/require_once the parent class that I am extending in PHP? for example
EDIT: Apparently the question is not clearly formulated enough. The issue I am having
In my project I have two classes, the EarleyParser class: class EarleyParser { public:
I have a vector declared as: vector<Curve> workingSet; Curve is a class I've created
The pure virtual destructor in base class should have a definition. Otherwise compiler will

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.