chenyong Posted October 5, 2011 Report Share Posted October 5, 2011 Hi, I found such codes as this: package uvm_config_prop_pkg; .... class uvm_config_prop #(type T=int) extends uvm_object; ..... static function void set_config (string target, string field, T value, uvm_component cntxt=null); uvm_config_prop #(T) wrapper = new(value); .... endfunction : set_config ... I was confused by the code with this: uvm_config_prop #(T) wrapper = new(value); how can a function belongs to a class to "new" a class as itself? Can anybody help me to understand this? thanks. Quote Link to comment Share on other sites More sharing options...
uwes Posted October 5, 2011 Report Share Posted October 5, 2011 hi, the magic of this is that the set_config is a static function (your are calling it upon the type and not upon an instance). so with that you say sometype::function() which calls function without having an instance. so this code is a static function which in its body allocates a dynamic object using new. /uwe Quote Link to comment Share on other sites More sharing options...
chenyong Posted October 6, 2011 Author Report Share Posted October 6, 2011 thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.