I've been working on this all day. My actual code is more complicated, but for now I'm stumped with the bit of code below. Running this, I get a referencing error, which seems absurd given the simplicity of the code. I'm just calling a private element within a class! However, various bad things have happened both in this and my more elaborate code, including lines and lines of random memory addresses and pathnames to "[heap]" or "[stack]" next to them. At a few points I got infinite loops from finite for iterations, but that will come later. For now, why can't I access this element?
Thank you, sasanet, for your helpful reply.
In the actual program, my array is allocated dynamically--but sticking to the present case, while I have made your changes, my main problem is that printMatrix doesn't print the value of M[0][0]. (Of course, if I can get it to give me this value, I will use a for loop as you suggest--but this is a very simple test program and I will be content with it if it will only display one element of my matrix class).
To be brief, even with the updated code (below), I cannot reach even the M[0][0] element, but instead get the error "Segmentation fault."