?
Solved

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

Posted on 2006-06-13
3
Medium Priority
?
720 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

752 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