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
Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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