Re: Strange array problem

From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 03/10/04


Date: Thu, 11 Mar 2004 00:39:36 +1100


"Sami Lakka" <sami.lakka@tut.fi> wrote in message news:c2n48r$t81$1@news.cc.tut.fi...
| Hi,
|
| I might be just missing something ridiculously simple but why does my arrays
| that
| are in private variables interfere with each other.
| Here is the output:
|
| 2 2 2 2
| 2 2 2 2
| 2 2 2 2
| 2 2 2 2
|
| 3 3 3 2 -- WHY THIS???
| 2 2 2 2
| 2 2 2 2
| 2 2 2 2

[snip]

Because, you are exceeding the array bounds, and
overwriting memory you don't own.

In your class you declare:

double matrix[3][3];

[snip]

Here you declare:

| const double MATRIX_SIZE = 4;

[snip]

Additionally, look through the magic numbers sprinkled
throughout your code, and you should immediately realise
where the errors are.

Cheers.
Chris Val



Relevant Pages

  • RE: Arrays - declaration, adding values to arrays and calculation
    ... Your declarations for bigdata and small data are fine, ... smalldata = Range.Resize ... I am a VBA beginner and would like to learn declaring arrays and using ... I want to declare three arrays BigData, ...
    (microsoft.public.excel.programming)
  • Re: initialising array of unknown size (newbie)
    ... help you if you copy the style of posting that is favoured here: snip ... will probably have to rewrite everything when you come to "wrap it up ... Note also that the code you cited does not really do 2D arrays. ... int i, j, k, row, col; ...
    (comp.lang.c)
  • Re: Performance of hand-optimised assembly
    ... DECLARE that those arrays are properly aligned and are suitable ... brittle machinery to DEDUCE that instead? ... usage of that variable it must be an int? ...
    (comp.lang.c)
  • Re: Help needed for a sorting code in the literature
    ... > because it can't be a library function: ... I have tested the speed of the heapsort code above on arrays of up to ... sorting needs, std::sortis significantly slower than dedicated ...
    (sci.crypt)
  • Re: Array Dimensions Change When Passed as Argument
    ... REAL arrays even when the COMPLEX data type existed. ... one of valuable aspects of Fortran over other languages is ... it is still in the standard. ...
    (comp.lang.fortran)