Trying to randomize a queue with inside operator. Not getting a desired outcome

In reply to saikanthan7798:

Please use code tags making your code easier to read. I have added them for you.
There was a syntax error in the second constraint that I fixed. This works for me:


class my_class;
  randc int queue [$]; //Unbounded queue

  function void display();
    $display("queue is %p",queue);
  endfunction

  constraint q_size { queue.size()==10; }

  constraint q_val {
    foreach(queue[i]) queue[i] inside {[30:39]};
  }
endclass

module top;
  my_class obj;

  initial begin
    obj=new();
    if (!obj.randomize()) $display("Randomization failed!");
    else obj.display();
  end
endmodule