本文整理汇总了C++中ItemType::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemType::Initialize方法的具体用法?C++ ItemType::Initialize怎么用?C++ ItemType::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemType
的用法示例。
在下文中一共展示了ItemType::Initialize方法的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")
示例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;
}