Re: Fruit basket program in C++/CLI

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Mon, 19 Nov 2007 08:39:04 -0500 (EST)

Yes, my undrstanding is that C++/CLI is essentially for C++ developers
who want to take advantage of the .NET Framework with the language and
associated features to which they have become accustomed.  Microsoft
submitted the language for international standardization, and this has
occurred, so theoretically other software publishers and platforms could
develop compilers for C++/CLI besides Microsoft Visual C++.  It is
unlikely that will happen practically speaking, however, because of the
inherent relation to .NET 2.0.

It is noteworthy that Microsoft's compiler can be used to create native
Win32 executables in standard C++ without any .NET dependencies.  In
other words, the CLI aspect adds language extensions, but not
requirements for a traditional C++ developer.

Jamal
On Mon, 19 Nov 2007, Marlon
Brandão de Sousa wrote:

> Date: Mon, 19 Nov 2007 09:32:13 -0200
> From: Marlon Brandão de Sousa <splyt.lists@xxxxxxxxx>
> Reply-To: programmingblind@xxxxxxxxxxxxx
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: Fruit basket program in C++/CLI
>
> Only to clarify, Lamar, this isn't c or c++. This is c Cli, which
> means it is a c++ modified language which allows the use of the .net
> stuff. If you want to develope for anything portable or non windows
> keep away from this for now and go learn the c++ language.
> This version of c++, the cli one, introduces some sintactical
> modifications (e.e the ^ symbol which seen to be a kind of pointer),
> and some other new things, but it won't compile out of microsoft
> compilers and it won't run out of windows ... well it won't run even
> on windows , if the .net is not installed on it.
>
> 2007/11/19, jaffar <jaffar@xxxxxxxxxxxxx>:
> > Hi Lamar.  No.  You'll need at least the .net 2.0 runtime to be able to run
> > it.  Cheers!
> > ----- Original Message -----
> > From: "Lamar Upshaw" <lupshaw@xxxxxxxxxxxxxx>
> > To: <programmingblind@xxxxxxxxxxxxx>
> > Sent: Monday, November 19, 2007 4:30 PM
> > Subject: Re: Fruit basket program in C++/CLI
> >
> >
> > > Just to clarify, I should be able to run this using minGW, correct?
> > >
> > > With All Respect,
> > > Upshaw, Lamar T
> > > ----- Original Message -----
> > > From: "Jamal Mazrui" <empower@xxxxxxxxx>
> > > To: <programmingblind@xxxxxxxxxxxxx>
> > > Sent: Sunday, November 18, 2007 8:14 PM
> > > Subject: Fruit basket program in C++/CLI
> > >
> > >
> > >> From the archive at
> > >> http://www.EmpowermentZone.com/cli_fruit.zip
> > >>
> > >> This fruit basket program is written in C++/CLI:  the C++ language with
> > >> extensions to support the Common Language Infrastructure of the .NET
> > >> Framework.  C++/CLI can create native Win32 executables or libraries,
> > >> .NET-based ones, or a combination of both.  Related development resources
> > >> that are freely available from Microsoft.com include the following:  the
> > >> .NET Framework 2.0 SDK, the Microsoft Platform SDK for Windows Server
> > >> 2003, and Visual C++ 2005 Express Edition.
> > >>
> > >> The archive includes a batch file, compile.bat, which invokes the
> > >> command-line compiler to create an executable, cli_fruit.exe, which is
> > >> about 5K in size.  The batch file initially sets environmental variables
> > >> that may need to be tweaked on another computer so that appropriate
> > >> directories are referenced.
> > >>
> > >> Besides the resulting executable, No other files are needed to run the
> > >> program -- as long as .NET 2.0 is installed.   The included Source code
> > >> is
> > >> also pasted below.
> > >>
> > >> Jamal
> > >>
> > >> /*;
> > >> content of cli_fruit.cpp;
> > >> Fruit Basket program in C++/CLI
> > >> //public domain by Jamal Mazrui
> > >> */;
> > >>
> > >> // Reference libraries
> > >> #using <System.dll>
> > >> #using <System.Windows.Forms.dll>
> > >>
> > >> // Import namespaces
> > >> using namespace System;
> > >> using namespace System::Windows::Forms;
> > >>
> > >> // Define class
> > >> ref class FruitBasket : public Form {
> > >> public :
> > >> //Define constructor
> > >> FruitBasket() {
> > >> // Initialize controls and set properties
> > >> tlp = gcnew TableLayoutPanel();
> > >> tlp->ColumnCount = 3;
> > >> tlp->RowCount = 2;
> > >>
> > >> lblFruit = gcnew Label();
> > >> lblFruit->Text = "&Fruit:";
> > >> tlp->Controls->Add(lblFruit);
> > >>
> > >> txtFruit = gcnew TextBox();
> > >> tlp->Controls->Add(txtFruit);
> > >>
> > >> btnAdd = gcnew Button();
> > >> btnAdd->Text = "&Add";
> > >> btnAdd->Click += gcnew EventHandler(this, &FruitBasket::Button_Click);
> > >> tlp->Controls->Add(btnAdd);
> > >>
> > >> lblBasket = gcnew Label();
> > >> lblBasket->Text = "&Basket:";
> > >> tlp->Controls->Add(lblBasket);
> > >>
> > >> lstBasket = gcnew ListBox();
> > >> tlp->Controls->Add(lstBasket);
> > >>
> > >> btnDelete = gcnew Button();
> > >> btnDelete->Text = "&Delete";
> > >> btnDelete->Click += gcnew EventHandler(this, &FruitBasket::Button_Click);
> > >> tlp->Controls->Add(btnDelete);
> > >>
> > >> Text = "Fruit Basket";
> > >> AcceptButton = btnAdd;
> > >> StartPosition = FormStartPosition::CenterScreen;
> > >> AutoSize = true;
> > >> AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
> > >> Controls->Add(tlp);
> > >> } // FruitBasket constructor
> > >>
> > >> // Define destructor
> > >> virtual ~FruitBasket() {
> > >> } // FruitBasket destructor
> > >>
> > >> // Define event handler;
> > >> void Button_Click(Object^ sender, EventArgs^ e) {
> > >> if (sender == btnAdd) {
> > >> String^ sFruit = txtFruit->Text->Trim();
> > >> if (sFruit->Length == 0) {
> > >> MessageBox::Show("No fruit to add!", "Alert");
> > >> return;
> > >> }
> > >>
> > >> lstBasket->Items->Add(sFruit);
> > >> txtFruit->Clear();
> > >> lstBasket->SelectedIndex = lstBasket->Items->Count - 1;
> > >> }
> > >> else if (sender == btnDelete) {
> > >> int iFruit = lstBasket->SelectedIndex;
> > >> if (iFruit == -1) {
> > >> MessageBox::Show("No fruit to delete->", "Alert");
> > >> return;
> > >> }
> > >>
> > >> lstBasket->Items->RemoveAt(iFruit);
> > >> if (iFruit == lstBasket->Items->Count) iFruit--;
> > >> lstBasket->SelectedIndex = iFruit;
> > >> }
> > >> } // Button_Click event handler
> > >>
> > >> // Declare controls;
> > >> TableLayoutPanel^ tlp;
> > >> Label^ lblFruit;
> > >> TextBox^ txtFruit;
> > >> Button^ btnAdd;
> > >> Label^ lblBasket;
> > >> ListBox^ lstBasket;
> > >> Button^ btnDelete;
> > >> }; // FruitBasket class
> > >>
> > >> // Define entry point of program
> > >> int main() {
> > >> Application::Run(gcnew FruitBasket());
> > >> return 0;
> > >> } // main method
> > >>
> > >> // End of cli_fruit.cpp
> > >>
> > >> __________
> > >> View the list's information and change your settings at
> > >> //www.freelists.org/list/programmingblind
> > >>
> > >
> > > __________
> > > View the list's information and change your settings at
> > > //www.freelists.org/list/programmingblind
> > >
> >
> > __________
> > View the list's information and change your settings at
> > //www.freelists.org/list/programmingblind
> >
> >
>
>
> --
> When you say "I wrote a program that crashed Windows," people just
> stare at you blankly and say "Hey, I got those with the system, for
> free."
> Linus Torvalds
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: