Array of Class handles "No implication of declaring a limit on no of handles?"

In reply to alexgran:

Yes, But i did some more experiments in the code to check on null objects for top[2] & top[3].
please follow the code and comments below.

original code was modified by adding a function ‘b’ to class “top”
Displaying Class objects in memory.
Call the function in the last portion of initial block.


class top;
  int a=1;
  function new(int i=0);
    $display("Class Handle %0d, A= %0d",i,this.a);
  endfunction

  //Added a function used later to see even the null objects can have this function definition which can be called
  function int b(int i=0);
    $display("Class Handle %0d,Calling function B ",i);
    return(i);
  endfunction
endclass

module test;
 top top1[2];
 initial
   begin
    top1[0] = new(0);
    top1[1] = new(1);
    top1[2] = new(2);
    top1[3] = new(3);

   //Displaying Class Objects created in foreach loop to see how many class objects exist
    foreach(top1[i])
      $display(top1[i]);  //will display 2 objects, probably for top[0] & top[1]
  
   //Displaying Class Objects created by manually specifying indexes
    $display(top1[0]);   //will display object of top[0]
    $display(top1[1]);   //will display object of top[1]
    $display(top1[2]);   // will show null @ simulation
    $display(top1[3]);   // will show null @ simulation
  
   //function B existing in each of the class can be called though! (both null and the existing)
    $display(top1[0].b(0)); 
    $display(top1[1].b(1));
    $display(top1[2].b(2));
    $display(top1[3].b(3));
  
   end
endmodule

Summary

The default foreach will only display only 2 class handles as you described.
By manually writing the indexes and displaying the class objects will show them as null.
But there exists pointers to function ‘b’ in each of the class objects?

Thanks
Parveez