Why Does This Pointer-Pointer Initialization Seg Fault?

With empty Soldier constructor your code works fine (except for corrected typos, like lowercase level. Soldier ).

With empty Soldier constructor your code works fine (except for corrected typos, like lowercase level. Soldier) Please post the constructor body.

The constructor was the problem, I was over-looking it all the while. Thanks. – strider24 Jan 28 '09 at 13:26.

I can not find any segfault related problems in your code. But I'm confused as to why your case sensitivity does not match: The class is called "Soldier" and the Soldier** is called "soldier". But you write: level.

Soldier = new soldier* level. SoldierCount; and: level. Soldieri = new Soldier(initX, initY, initDirection, steps); If the code really compiles as you've written it, this could be the problem.

My bad. Corrected the code now. – strider24 Jan 28 '09 at 13:24 Always copy/paste source code when showing it to others.

If we can't be sure that the code you posted is the code you have, how can we possibly answer the question? Copy/paste, so you don't introduce typos or other errors that aren't there in the actual code you're working with. – jalf Jan 28 '09 at 13:27 I was playing around with markdown and messed it up.Sorry.

– strider24 Jan 28 '09 at 13:29.

What is the value of level. SoldierCount? What is the value of I The only way a segfault can occur is if you access unallocated memory.In the line you highlighted, the only place that can happen is in the array (or inside the constructor, which you didn't post the code for).

Most likely, you're accessing the array out of bounds.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions