Solved

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

Posted on 2006-06-13
3
701 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now