How to create the queue array of class from text file

In reply to rupeshblr:

You are still doing wrong things.
See the working code here:

module testbench ();
 
class Packet ;
 
logic [31:0] addr;
logic [31:0] data;
logic [31:0] wmask;
logic [31:0] rmask;
 
  //function new ();
  //endfunction
 
endclass
 
  logic [31:0] addr_;
  logic [31:0] data_;
  logic [31:0] wmask_;
  logic [31:0] rmask_;
 
  Packet  qu[$]; 
  int fd;
  int i = 0;
 
  initial
     begin
       Packet p1;
       fd = $fopen ("data.txt" , "r");
// $fscanf returns the number of matches, i.e. 4 in your case
       while ($fscanf (fd, "%0h %0h %0h %0h", addr_, data_, wmask_, rmask_) == 4) begin
 
         p1 = new ;
         p1.addr = addr_;
         p1.data = data_;
         p1.wmask = wmask_;
         p1.rmask = rmask_ ;
         //$display ("addr_ %h , data_ %h wmask_ %h , rmask_ %h",p1.addr, p1.data, p1.wmask, p1.rmask);
         qu.push_back(p1);
	 $display("qu size = %0d", qu.size);
  end 
$fclose(fd);
         foreach (qu[i])
           begin
             $display ("queue of class [%0d] = %h , %h, %h , %h" , i , qu[i].addr, qu[i].data, qu[i].wmask,  qu[i].rmask);
 
          end
     end  
 
endmodule