Access Violation Error & Rectangular Arrays
xycos
xycos at u.washington.edu
Mon Aug 21 18:44:26 PDT 2006
Hello,
I apologize for asking such n00bish questions... I come from a C#/Java
background, and have never programmed with explicit pointers before.
Two questions -- First, why won't this work?
int main(char[][] args) {
Bar baz = new Bar();
for(int i = 0; i < 5; i++) {
writefln(baz.arr[i].x);
}
return 0;
}
class Foo {
public int x;
this(int y) {
x = y;
}
}
class Bar {
public Foo*[5] arr;
public this() {
for(int i = 0; i < 5; i++) {
Foo z = new Foo(i);
arr[i] = &z;
}
}
}
It gives me an "access violation"... The GC shouldn't have killed
anything; I still have pointers, neh?
Second question: Is there any way to define a rectangular array (one
of the optimized ones, not the dynamic-arrays-of-arrays things) that
has its size determined at compile time?
Thanks!
Best of wishes,
Robert
More information about the Digitalmars-d-learn
mailing list