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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:36:13+00:00 2026-06-12T15:36:13+00:00

I have a program that contains a doctor class, and each Doctor object has

  • 0

I have a program that contains a doctor class, and each Doctor object has a linked list of “Patients”. These patients are created using the following line of code

Patient * patient = new Patient(string firstname, string ailment);

And this patient is then added to a Doctor’s linked list.
There is a pointer in the Doctor class that is used to point to and iterate through the list and get each patient. When I want to delete these patients, I have to start at the beginning of my list and iterate through each one. My question is, can I delete eacg patient by simply calling their destructors as I iterate through them?

Patient::~Patient(){

}

or do I need to actually call delete on the pointer as it points each employee?

  • 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-12T15:36:14+00:00Added an answer on June 12, 2026 at 3:36 pm

    You call delete to delete things. delete will, in turn, result in the object’s destructor being called.

    Calling the destructor of a class directly is supported by C++, and is in fact useful in some rare scenarios, but it does not actually deallocate the memory. This is not what you want to do here.

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

Sidebar

Related Questions

I have a program with a class that contains a public enum, as follows:
I am creating a program that encrypts/hashs messages I have a list that contains
all. Let's say I have a program that contains a long list of C
I have a ItemsControl in my program that contains a list of radio buttons.
I need to make the program which have one form that contains PNG image
I have a table that contains log entries for a program I'm writing. I'm
I have program that has a variable that should never change. However, somehow, it
I have a program that gets a JSON from the server using getJSON and
Currently I have a program that takes as input a folder that contains .MPP
I have a structure in my program that contains a particular array. I want

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.