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 3 of 11)

September, 2005: C++/CLI: Cloning

Listing 1

using namespace System;
using namespace System::Collections;

void PrintEntries(String^ s, ArrayList^ aList);

int main()
{
     ArrayList^ al1 = gcnew ArrayList;
/*1*/     al1->Add("Red");
     al1->Add("Blue");
     al1->Add("Green");
     al1->Add("Yellow");
/*2*/     PrintEntries("al1", al1);
/*3*/     ArrayList^ al2 = static_cast<ArrayList^>(al1->Clone());
/*4*/     PrintEntries("al2", al2);
/*5*/     al1->Remove("Blue");
     al1->Add("Black");
     al1->RemoveAt(0);
     al1->Insert(0, "Brown");

/*6*/     PrintEntries("al1", al1);
/*7*/     PrintEntries("al2", al2);
}
void PrintEntries(String^ s, ArrayList^ aList)
{
     Console::Write("{0}: ", s);
     for each(Object^ o in aList)
     {
          Console::Write("\t{0}", o);
     }
     Console::WriteLine();
}

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