Solved

Quick C++ -> C# port Question : Octree *m_children[8]; becomes???

Posted on 2006-06-13
3
714 Views
Last Modified: 2012-06-21
Im following a tutorial as such:

http://kurtm.flipcode.com/devlog-OctreesforPotentialColliders.shtml

Basically we have a constructor:

    Octree()
    {
        for(int i=0; i<8; i++)
        {
            m_children[i] = NULL;
         }
    }

Which setups up the octree

The thing is at the bottom we declare m_children :

Octree      *m_children[8];

Which is basically the type Octree which has pointer to an array of 8???

Sorry just mixing things up here a little.

0
Comment
Question by:directxBOB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:directxBOB
ID: 16900115
Just to update:

  MTOcTree[] children = new MTOcTree[8];

This is what I have ported too, I believe it to be correct but I could be completely reading it arse ways,.... Damn Java has corrupted me.
0
 
LVL 21

Accepted Solution

by:
MogalManic earned 500 total points
ID: 16901258
You are basically correct.  One of the uses of pointers in C++ is so that the object gets allocated on the heap instead of the stack.  If the C++ programmer of had declared
  Octree      m_children[8];
the program would have created 8 Octree objects INSIDE the contained class.

This is not the case inc C#.  In C# all object declarations are in actuality just a handle, so you are correct in that in C# the code should read
  MTOcTree[] children = new MTOcTree[8];
which means declare array of 8 handles to MTOcTree objects
0
 

Author Comment

by:directxBOB
ID: 16907899
excellent thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question