topical media & game development

talk show tell print


? / basic-program-code-09-Ex9-16-Ex9-16.c

  // Ex9_16.cpp : main project file.
  // Using a class library in a separate assembly
  include <stdafx.h>
  include <GlassBox.h>
  #using <Ex9_16lib.dll>
  using namespace System;
  using namespace Ex9_16lib;
  int main(array<System::String ^> ^args)
   array<IContainer^>^ containers = { gcnew Box(2.0, 3.0, 4.0),
                                      gcnew GlassBox(2.0, 3.0, 4.0),
                                      gcnew Box(4.0, 5.0, 6.0),
                                      gcnew GlassBox(4.0, 5.0, 6.0)
    Console::WriteLine(L"The array of containers have the following volumes:");
    for each(IContainer^ container in containers)
      container->ShowVolume();           // Output the volume of a box
    Console::WriteLine(L"\nNow pushing the containers on the stack...");
    Stack^ stack = gcnew Stack;          // Create the stack
    for each(IContainer^ container in containers)
           L"Popping the containers off the stack presents them in reverse order:");
    Object^ item;
    while((item = stack->Pop()) != nullptr)
    return 0;

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.