Freigeben über


Simple stack code

We've got a code sample today, of a simple integer stack implemented using Whidbey
C++.  I'll implement it using three pieces of code:

- stack.h - definition of the stack

**stack.cpp** - implementation of the stack  
  • main.cpp - driver program that makes use of the stack

I compile the stack class into a DLL (stack.dll), which I then import into the main
program with #using.  The beauty of stack.dll is that it should be consumable
by any .NET-targeted language: C#, VB.NET, even ASP.NET.  In fact, to prove this,
I've also included drv.cs, a C# source file which consumes stack.dll.

Another benefit of using DLLs: during development, I found a bug in my stack program. 
I edited stack.cpp, recompiled the DLL, and ran main.exe again.  I didn't need
to recompile main! :)

To compile:

- stack.cpp as a DLL: cl /clr:newSyntax /LD stack.cpp

**main.cpp**: cl /clr:newSyntax main.cpp  
  • drv.cs: csc drv.cs /r:stack.dll

Get the files!   The code is available as a zip file: stack.zip.

Comments

  • Anonymous
    November 13, 2003
    I am a MVP in vc++ and I am interested in this sample.but I felt very sorry that I cannot download it,can you change the download location so that I can get the whole source
  • Anonymous
    November 14, 2003
    Sorry! I've updated the link so it points to a location that should stay valid longer. Thanks for letting me know.
  • Anonymous
    November 16, 2003
    thanks for your great job.
  • Anonymous
    April 14, 2004
    i want simple stack for posfix
  • Anonymous
    May 24, 2004
    i want simple code of stack please send me
  • Anonymous
    May 24, 2004
    i want simple code of stack please send me
  • Anonymous
    May 25, 2004
    i want stack array and linked lis stack thank you ...
  • Anonymous
    May 25, 2004
    i want stack array and linked lis stack thank you ...
  • Anonymous
    July 24, 2004
    thanks
  • Anonymous
    June 07, 2008
    We've got a code sample today, of a simple integer stack implemented using Whidbey C++.  I'll implement it using three pieces of code: stack.h - definition of the stack stack.cpp - implementation of the stack main.cpp - driver program that make
  • Anonymous
    June 02, 2009
    PingBack from http://indoorgrillsrecipes.info/story.php?id=11691