当前位置: 首页>>代码示例>>C++>>正文


C++ ItemType::Print方法代码示例

本文整理汇总了C++中ItemType::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemType::Print方法的具体用法?C++ ItemType::Print怎么用?C++ ItemType::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ItemType的用法示例。


在下文中一共展示了ItemType::Print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{

  ifstream inFile;       // file containing operations
  ofstream outFile;      // file containing output
  string inFileName;     // input file external name
  string outFileName;    // output file external name
  string outputLabel;     
  string command;        // operation to be executed
  
  int number;
  ItemType item;
  UnsortedType list;
  bool found;
  int numCommands;


  // Prompt for file names, read file names, and prepare files
  cout << "Enter name of input command file; press return." << endl;
  cin  >> inFileName;
  inFile.open(inFileName.c_str());

  cout << "Enter name of output file; press return." << endl;
  cin  >> outFileName;
  outFile.open(outFileName.c_str());

  cout << "Enter name of test run; press return." << endl;
  cin  >> outputLabel;
  outFile << outputLabel << endl;
  if (!inFile)
  {
    cout << "file not found" << endl;
	exit(2);
  }
  inFile >> command;

  numCommands = 0;
  while (command != "Quit")
  { 
    if (command == "PutItem")
    {
      inFile >> number; 
      item.Initialize(number);
      list.PutItem(item);
      item.Print(outFile);
      outFile << " is in list" << endl;
    }
    else if (command == "DeleteItem")
开发者ID:Abeer88,项目名称:ECE_Material,代码行数:48,代码来源:listDriver.cpp

示例2: main

int main()
{
    ItemType item[MAX_ITEM];
    SortedType list;
    
    item[0].Initialize(67);
    item[1].Initialize(89);
    item[2].Initialize(100);
    item[3].Initialize(12);
    item[4].Initialize(32);
    
    
    for(int i = 0; i < MAX_ITEM; i++)
    {
        list.InsertItem(item[i]);
    }
    
    list.IsFull() ? cout << "List is not empty" : cout << "list is empty";
    cout << endl;
    
    cout << "Length of the list is : " << list.LengthIs() << endl;
    
    cout << "Contents of the list : ";
    FOR()
    {
        ItemType printItem;
        
        list.GetNextElement(printItem);
        printItem.Print();
    }
    cout << endl;
    cout << endl;
    
    
    int key;
    ItemType deleteKey;
    cout << "Enter what you want to delete : ";
    cin >> key;
    deleteKey.Initialize(key);
    
    list.DeleteItem(deleteKey);
    
    cout << "After deletion the length of the list : " << list.LengthIs() << endl;
    cout << "Contents of the list  after deletion : ";
    list.ResetList();
    for(int i = 0; i < list.LengthIs(); i++)
    {
        ItemType printItem;
        
        list.GetNextElement(printItem);
        printItem.Print();
    }

    cout << endl;
    
    cout << "Emptying the list........." << endl;
    list.MakeEmpty();
    list.IsFull() ? cout << "List is not empty" : cout << "list is empty";
    cout << endl;
    
    cout << "Resetting the list.............." << endl;
    list.ResetList();
    
    
    
    return 0;
}
开发者ID:ShawonAshraf,项目名称:CSE225CodesNSU,代码行数:67,代码来源:main.cpp


注:本文中的ItemType::Print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。