I
I
ikutin6662021-09-28 12:38:54
C++ / C#
ikutin666, 2021-09-28 12:38:54

Why inherit from ICloneable?

class cl1 :  ICloneable
{
      public object Clone()
      {
         return new cl1();
      }
}


class cl1
{
      public cl1 Clone()
      {
         return new cl1();
      }
}


why is the first option used in most examples? if more practical option 2?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-09-28
@ikutin666

Actually, you can combine them :)
And the first option is needed so that you can cast to ICloneable and not know what we are cloning there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question