cores=new[no_cores] is procedural code; it can’t hang around with variable declarations.
class myclass;
rand int no_of_transactions;
int no_cores = 8;
int no_of_transactions_max = 10;
int no_of_transactions_min = 1;
int cores;
function void init_memory();
cores = new[no_cores]; // <---- my new home!
endfunction
endclass