Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. C++ Issue: Forgotten Virtual Destructor - Need Help Resolving!

C++ Issue: Forgotten Virtual Destructor - Need Help Resolving!

Scheduled Pinned Locked Moved JavaScript
helpoopquestionc++com
4 Posts 3 Posters 15 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tammy Gombez
    wrote on last edited by
    #1

    Greetings fellow C++ developers, I'm currently facing a perplexing issue in my C++ code that seems to be related to a forgotten virtual destructor. I'm reaching out to this forum in the hopes that someone can help me resolve this problem and also I am using currently i7 laptop it is working fine not problem in it. Here are the details: Programming Language: C++ The issue I'm experiencing is a potential memory leak or undefined behavior due to not having a virtual destructor in one of my base classes. I suspect this is causing problems when I try to delete derived objects through base class pointers. Here's a brief explanation of the situation: Code Structure: I have a base class, let's call it Base, and several derived classes that inherit from it. Inheritance Hierarchy: The derived classes have their own specific behaviors and additional member variables. Base Class Destructor: Initially, I overlooked adding a virtual destructor in the Base class. Object Deletion: I'm creating objects of derived classes dynamically and storing their addresses in base class pointers. Later, I attempt to delete these objects through the base class pointers. Issue Arising: During program execution, I noticed potential memory leaks or undefined behavior when deleting these objects. After some investigation, I suspect it's due to not having a virtual destructor in the base class. I've already tried a few things to mitigate this issue, such as: Adding a virtual destructor to the Base class and recompiling the code. Testing object deletion again, but the problem still persists. Given the circumstances, I'm seeking advice and suggestions from experienced C++ developers who have encountered similar situations or have deep knowledge of C++ destructors and polymorphism. How can I rectify this issue and ensure proper object deletion? If you require any additional code snippets or further context to better understand the problem, please let me know, and I'll be more than happy to provide them. Thank you in advance for your valuable insights and assistance! Best regards, Tammy Gombez

    Richard DeemingR L 2 Replies Last reply
    0
    • T Tammy Gombez

      Greetings fellow C++ developers, I'm currently facing a perplexing issue in my C++ code that seems to be related to a forgotten virtual destructor. I'm reaching out to this forum in the hopes that someone can help me resolve this problem and also I am using currently i7 laptop it is working fine not problem in it. Here are the details: Programming Language: C++ The issue I'm experiencing is a potential memory leak or undefined behavior due to not having a virtual destructor in one of my base classes. I suspect this is causing problems when I try to delete derived objects through base class pointers. Here's a brief explanation of the situation: Code Structure: I have a base class, let's call it Base, and several derived classes that inherit from it. Inheritance Hierarchy: The derived classes have their own specific behaviors and additional member variables. Base Class Destructor: Initially, I overlooked adding a virtual destructor in the Base class. Object Deletion: I'm creating objects of derived classes dynamically and storing their addresses in base class pointers. Later, I attempt to delete these objects through the base class pointers. Issue Arising: During program execution, I noticed potential memory leaks or undefined behavior when deleting these objects. After some investigation, I suspect it's due to not having a virtual destructor in the base class. I've already tried a few things to mitigate this issue, such as: Adding a virtual destructor to the Base class and recompiling the code. Testing object deletion again, but the problem still persists. Given the circumstances, I'm seeking advice and suggestions from experienced C++ developers who have encountered similar situations or have deep knowledge of C++ destructors and polymorphism. How can I rectify this issue and ensure proper object deletion? If you require any additional code snippets or further context to better understand the problem, please let me know, and I'll be more than happy to provide them. Thank you in advance for your valuable insights and assistance! Best regards, Tammy Gombez

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      What has this got to do with JavaScript? C++ questions belong in a C++ forum: C / C++ / MFC Discussion Boards[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • T Tammy Gombez

        Greetings fellow C++ developers, I'm currently facing a perplexing issue in my C++ code that seems to be related to a forgotten virtual destructor. I'm reaching out to this forum in the hopes that someone can help me resolve this problem and also I am using currently i7 laptop it is working fine not problem in it. Here are the details: Programming Language: C++ The issue I'm experiencing is a potential memory leak or undefined behavior due to not having a virtual destructor in one of my base classes. I suspect this is causing problems when I try to delete derived objects through base class pointers. Here's a brief explanation of the situation: Code Structure: I have a base class, let's call it Base, and several derived classes that inherit from it. Inheritance Hierarchy: The derived classes have their own specific behaviors and additional member variables. Base Class Destructor: Initially, I overlooked adding a virtual destructor in the Base class. Object Deletion: I'm creating objects of derived classes dynamically and storing their addresses in base class pointers. Later, I attempt to delete these objects through the base class pointers. Issue Arising: During program execution, I noticed potential memory leaks or undefined behavior when deleting these objects. After some investigation, I suspect it's due to not having a virtual destructor in the base class. I've already tried a few things to mitigate this issue, such as: Adding a virtual destructor to the Base class and recompiling the code. Testing object deletion again, but the problem still persists. Given the circumstances, I'm seeking advice and suggestions from experienced C++ developers who have encountered similar situations or have deep knowledge of C++ destructors and polymorphism. How can I rectify this issue and ensure proper object deletion? If you require any additional code snippets or further context to better understand the problem, please let me know, and I'll be more than happy to provide them. Thank you in advance for your valuable insights and assistance! Best regards, Tammy Gombez

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Tammy Gombez wrote:

        I'm currently facing a perplexing issue

        Do you mean why have you posted a C++ question in the Javascript forum?

        Richard DeemingR 1 Reply Last reply
        0
        • L Lost User

          Tammy Gombez wrote:

          I'm currently facing a perplexing issue

          Do you mean why have you posted a C++ question in the Javascript forum?

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          More like "How do I get banned for spam as quickly as possible?" :) Spammer in JavaScript forum (Tammy Gombez)[^]


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups