Accessing struct defined in a class

I have a struct defined inside a class as follows:

 
class test;

typedef struct packed{
logic c;
logic d;

}pkd_flds_s;

endclass

I’m trying to access members of this struct inside another class as follows:
test t;
t = new();

logic l = t.pkd_flds_s.c; //Method-1
logic l = t.c; //Method-2

Using both these methods I get the error: Cold not find member “c” in class ‘test’. How can I access the elements c and d in another class?

In reply to vikrant_sharma:

You have only declared the type, not a variable.

In reply to dave_59:

I also tried to do declare a variable of type pkd_flds_s as follows but it didn’t work. Is this what you were suggesting?



test t;
t = new();
t.pkd_flds_s inst; // Create a variable of type pkd_flds_s
logic l = inst.c; 


In reply to vikrant_sharma:

It would help to show a complete example. The following worked for me

module top;
  class test;
    typedef struct packed{
      logic c;
      logic d;
    } pkd_flds_s;
  endclass
  test t;
  test::pkd_flds_s inst;
  logic l;
  initial begin
    t = new();
    inst.c = 1;
    l = inst.c; 
    $display(l);
  end
endmodule