How to class instantiate with another class?

Hi,
I am faced the error.
** Error: design.sv(4): Invalid type ‘transaction_data’. Please check the type of the variable ‘data’.
** Error: design.sv(4): near “(”: syntax error, unexpected ‘(’, expecting function or task
End time: 15:10:18 on Jul 01,2017, Elapsed time: 0:00:00
Errors: 2, Warnings: 0

class common_mailbox;

mailbox box=new();
transaction_data data;

function new();
  data=new();
  $display("completed");
 endfunction

endclass

class transaction_data;

bit [7:0]input_axis_tdata=8’d5;
bit clk=1;
bit reset=0;
bit input_axis_tvalid=1;
bit [15:0]prescale=3;
bit input_axis_tready=1;

endclass

module top;
common_mailbox common;

initial begin
common=new();
end
endmodule

In reply to Rajaraman R:

You need to define the class ‘transaction_data’ before you use it. Put it before ‘common_mailbox’.

In reply to cgales:

Thanks CGALES…

But it was not working, and why to before put it…

In reply to Rajaraman R:

In order to parse your code, SystemVerilog needs to know that an identifier is a type before it can be referenced within your code. So you need to put the class declaration of transaction_data before it is referenced inside class common_mailbox. There is also something called a forward typedef that can be placed before an undeclared class. See section 6.18 in the IEEE 1800-2012 LRM.

Also, I strongly recommend that you declare your mailbox parameterized by the class type you will be putting into it.

In reply to dave_59:

Thanks DAVE…

   But parameterized class only uses the same data type.But i want store a one class object and reterive from the other class. Ex. I have a common mailbox class,transaction class and driver class.The values are stimules in a  transaction class then transaction class object will be stored into common mailbox class using put method.Then i want to reterive transaction class object to the driver class using get method

first transaction object will be put to the common mailbox and get to the driver class object using mailbox get method…