Having instances of Both Child class and Parent class within a module

Hi, Below is my code where I have set and get methods for both parent class and child class.
Some methods are extern ( outside of the class)
I am trying to create a handle to the child class within a module but its resulting in a “Syntax error”
Question : Is it really some basic issue with my code or I cannot have parent class and child class instances within a module?

My Code:

//PARENT CLASS
class parentclass;
  int data;
  bit[56:0] addr;
  
  function void set(int data, bit[56:0] addr);
    this.data=data;
    this.addr=addr;
  endfunction
  
  function void get;
    $display("The value of addr and data is %0h and %0d",this.addr, this.data);
  endfunction
  
  extern function void set_outside(int data, bit[56:0] addr);
  extern function void get_outside();  
endclass
//EXTERN METHODS
      function void parentclass::set_outside(int data, bit [56:0] addr);
          this.data = data;
          this.addr= addr;
      endfunction                  

      function void parentclass::get_outside();
          $display("Get Outside Method called : The value of addr and data is %0h and %0d",this.addr, this.data);
      endfunction

//CHILD CLASS        
class childclass extends parentclass;
        string rd_wr;
        
        function void set_rd_wr(string rd_wr);
          this.rd_wr=rd_wr;
        endfunction
          
        extern function void get_rd_wr();
endclass    
          
function void  childclass::get_rd_wr;
        $display("The value of address is %0h \n The value of data is %0d \n, The value of read-write type is %0s", this.addr,this.data,this.rd_wr);
endfunction

//MODULE WHERE CLASSES ARE DECLARED
module tb;
  initial begin
    parentclass p1 = new;
    p1.set(55,'h900);
    p1.get;
    p1.set_outside(66, 'h1000);
    p1.get_outside();
    
    childclass c1;   // IS SOMETHING WRONG WITH THIS LINE???
    //c1.set_rd_wr("READ");
    //c1.get_rd_wr;

  end
endmodule

ERROR OBSERVED: ( output log)

Error-[SE] Syntax error
Following verilog source has syntax error :
“testbench.sv”, 52: token is ‘c1’
childclass c1;

^

1 error
CPU time: .274 seconds to compile
Exit code expected: 0, received: 1

move the instance declaration before the procedural code.



module tb;
  initial begin
     childclass c1;
    parentclass p1 = new;
    p1.set(55,'h900);
    p1.get;
    p1.set_outside(66, 'h1000);
    p1.get_outside();
 
      // IS SOMETHING WRONG WITH THIS LINE???
    //c1.set_rd_wr("READ");
    //c1.get_rd_wr;
 
  end
endmodule


In reply to rag123:

To add to rag123, a variable declaration whether it be a class or any other type must come before any procedural statement within a procedural block of code. (begin/end, fork/join, task/function). This is a BNF restriction.

In reply to dave_59:

Thankyou for the response