Re: Unhandled exception..
This is Managed C++, so you'll get more help in that forum. (Native C++ does not have a namespace "System", for one, nor does it use the ^ symbol in that way.)
However, I do find it suspicious that a j-based for loop is incrementing i instead of j.
Re: Unhandled exception..
Re: Unhandled exception..
I agree with Lindley about the i++ in that loop being suspicious.
It looks to me like in the loop where you're deleting your Satellite objects that since you're never incrementing j and incrementing i instead that you'll go into an infinite loop until it tries to delete something which doesn't exist... causing your crash. If you commented out that delete line, you'd probably find that it would just sit there looping forever instead of crashing.
Long story short: try a j++ in that for loop instead of an i++.
Re: Unhandled exception..
Quote:
Originally Posted by
Lindley
This is Managed C++, so you'll get more help in that forum. (Native C++ does not have a namespace "System", for one, nor does it use the ^ symbol in that way.)
However, I do find it suspicious that a j-based for loop is incrementing i instead of j.
I have tried to use * for pointer but I had problems with passing Random variable to function.
This is how I found it working.
i++ in j for loop it definitely my mistake.. but even after correction it does not solve the problem. Error still occurs on one of two lines I mentioned before.
Re: Unhandled exception..
Did you run in Debug-Mode?
I didn't programm C++ for a few years now, but I believe the Debugger should jump to the line where the exception is thrown, shouldn't it?
From there you should be able to inspect the contents of your variables and maybe use breakpoints to examine what goes wrong.
I can only recommend you to learn the debugger.
Re: Unhandled exception..
Your destructor looks pretty strange.
doesn't this work?
Code:
StellarObject::~StellarObject()
{
for(int i = 0; i < this->NoOfSatelites; i++)
{
// i suppose this should call the destructor and thus there
// is no need to walk through it's children and delete them
delete this->Satelite[i];
}
delete[] this->Satelite;
}
Same goes for your PrintSystem() Method. It's pretty weird.