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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:18:06+00:00 2026-06-18T22:18:06+00:00

So I wrote an octree struct, as follows: struct octree{ static const int maxdepth=8;

  • 0

So I wrote an octree struct, as follows:

struct octree{
    static const int maxdepth=8;
    octree* child[8];
    uint32_t rgb;//candidates for the extra 8 bits: alpha, lighting, shape(to reduce size)
    uint8_t shape;
    ~octree(){delete[] child;}
};

The concern that I have is with the destructor…
Will it call the destructors of the children or do I have to do that myself?

  • 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-18T22:18:07+00:00Added an answer on June 18, 2026 at 10:18 pm

    What you have declared is an array of 8 octree* values. You cannot delete the array itself.

    You should instead do this:

    for( int i = 0; i < 8; i++ )
        if( child[i] ) delete child[i];
    

    If you want to delete them all in one hit, you could define it like this:

    octree * child;
    
    //...
    child = new octree [8];
    
    //...
    delete [] child;
    

    The reason being that in an octree you either have no children or 8 children.

    And yes: when you delete an octree instance, its destructor will be called.

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

Sidebar

Related Questions

I wrote a simple counter structure in C: typedef struct{ int value; }Counter; then,
I wrote a program #include <stdio.h> #include <unistd.h> int main() { int returnVal =
I wrote the sentence as follows: allLinkValues = ie.getLinksValue('class') but the return values are
I wrote a util class to filter elements in java.util.Collection as follows: public class
I wrote a small sparse matrix class with the member: std::map<int,std::map<int,double> > sm; The
I wrote a small coordinate class to handle both int and float coordinates. template
Wrote a login custom dialogbox static LoginDialog loginDialog; public static bool ShowLoginDialog() { result
I wrote out a matrix in Fortran as follows: real(kind=kind(0.0d0)), dimension(256,256,256) :: dense [...CALCULATION...]
Wrote a quick Java proggy to spawn 10 threads with each priority and calculate
I wrote a symfony task to fill a database of sample data. Here's a

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.