|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
请问下大家,在看绿皮书时,对象的复制看不懂,下面的代码:class Transaction
bit [31:0] addr, crc, data[8];
static int count = 0;
int id;
Statistics stats;
function new;
stats = new();
id = count++;
endfunction
endclass
Transaction src, dst;
initial begin
src = new(); //创建一个Transaction对象
src.stats.startT = 42;
dst = new src; //用new操作符将src拷贝到dst中,结果dst与src一样
dst.stats.startT = 96;
$display(src.stats.startT);
end
复制完以后,dst与src指向同样的内容,但是为什么改变了dst,src指向的内容会改变?还有什么叫shallow copy?
谢谢! |
|