FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
September 01, 2005

C++/CLI: Cloning

(Page 9 of 11)

September, 2005: C++/CLI: Cloning

Listing 7

using namespace System;

public ref class Derived : Base, ICloneable
{
     array<int>^ dPair;
public:
     Derived(int bi, int bj, int i, int j) : Base(bi, bj)
     {
          dPair = gcnew array<int>(2) {i, j};
     }
     void SetValue(int bi, int bj, int i, int j)
     {
          Base::SetValue(bi, bj);
          dPair[0] = i;
          dPair[1] = j;
     }
     virtual String^ ToString() override
     {
          return String::Concat("[{", Base::ToString(),
               "}", dPair[0], ":", dPair[1], "]");
     }
     virtual Object^ Clone() override
     {
          Derived^ d = static_cast<Derived^>(Base::MemberwiseClone());
//        Derived^ d = static_cast<Derived^>(Base::Clone());
          d->dPair = static_cast<array<int>^>(dPair->Clone());
          return d;
     }
};

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK