Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 4 159
Remove greater than sign 3 42
About delegates in c sharp 3 31
Angular JS Route 3 45
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

19 Experts available now in Live!

Get 1:1 Help Now