function struct(){
  this.a = null;
  this.b = null;
  this.c = null;
}var st1 = new struct();
st1.a = "a";
st1.b = "b";
st1.c = "c";
var st2 = new struct();
st2.a = "d";
st2.b = "e";
st2.c = "f";var arr = new Array(st1, st2);for (i=0; i<arr.length; i++)
{
var print = "st" + i + ".a = " + arr[i].a + "\n";
print += "st" + i + ".b = " + arr[i].b + "\n";
print += "st" + i + ".c = " + arr[i].c + "\n";
alert(print);
}

解决方案 »

  1.   

    可以阿,定义一个数组,再赋予这个数组每个元素为一个类的对象.<SCRIPT LANGUAGE="JavaScript">
    function a(val1)
    {
    this.b = val1;
    }
    var ary = new Array;
    ary[ary.length] = new a('a');
    ary[ary.length] = new a('b');alert(ary[0].b);
    alert(ary[1].b);
    </SCRIPT>
      

  2.   

    假如定义下标为10的结构数组,不能一次搞定吗?如:
    int nTest[10];
    之类的形式。
    如果照上面的说法,岂不是要这样:
    int n1 = new int();
    int n2 = new int();
    int n3 = new int();
    ...
    int n10 = new int();int nTest =