ex10_13.cpp

来自「Wrox.Ivor.Hortons.Beginning.Visual.C.Plu」· C++ 代码 · 共 35 行

CPP
35 行
字号
// Ex10_13.cpp
// Storing handles in a vector

#include "Person.h"
#include <cliext/vector>

using namespace System;
using namespace cliext;

int main(array<System::String ^> ^args)
{
  vector<Person^>^ people = gcnew vector<Person^>(); 
  String^ first;             // Stores a first name
  String^ second;            // Stores a second name
  Person^ person;            // Stores a Person

  while(true)
  {
    Console::Write(L"Enter a first name or press Enter to end: ");
    first = Console::ReadLine();
    if(first->Length == 0)
      break;
    Console::Write(L"Enter a second name: ");
    second = Console::ReadLine();
    person = gcnew Person(first->Trim(),second->Trim());
    people->push_back(person);
  }

  // Output the contents of the vector
  Console::WriteLine(L"\nThe persons in the vector are:");
  for each(Person^ person in people)
    Console::WriteLine("{0}",person);
  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?