开发者

Impossible to create interface field when copy an object

given this class definition:

  public class Frame
    {
        IFrameStream CapturedFrom;
  开发者_Python百科  }

I want implement Clone() method in this class, but problem is:

How to create the IFrameStream field in the destination instance? - I just don't know its implementation, how to create the instance?


Think of the semantics. In other words, what does the CapturedFrom field mean?

From your code, I assume that it would make sense to set the CapturedFrom field of the new instance in the Clone() method to the same value as the CapturedFrom field of the source instance. This is what's usually known as a "shallow copy".

Alternatively, you can leave it null. After all, the new instance hasn't been captured from a stream but cloned anew.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜