本文整理汇总了C++中DoublyLinkedList::add_item方法的典型用法代码示例。如果您正苦于以下问题:C++ DoublyLinkedList::add_item方法的具体用法?C++ DoublyLinkedList::add_item怎么用?C++ DoublyLinkedList::add_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoublyLinkedList
的用法示例。
在下文中一共展示了DoublyLinkedList::add_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
cout<<"\t\t\t\t>>SORTED<<\n\t\t\t>>Doubly Linked List<<\n\n";
int op; //variable to store choice of operation
int value; //variable to store value into node
char ext; //variable to exit loop
int cnt; //variable to store count of nodes
int search=2; //variable to store search results
DoublyLinkedList<int> obj; //created object of Doubly linked list
do
{
cout<<"\t\tWhat to do?\n1. Add Item\n2. Delete from Head\n3. Delete from Tail\n4. Search Data in List\n5. Delete Node with Specific Data\n6. Check Total Number of Nodes\n7. Print List\n\tYour Choice = "; cin>>op;
if(op==1)
{
cout<<"Enter Value to be stored = ";
cin>>value;
obj.add_item(value);
}
else if(op==2)
{
obj.deletefromDLLhead();
}
else if(op==3)
{
obj.deletefromDLLtail();
}
else if(op==4)
{
cout<<"Enter Data to Search = "; cin>>value;
search = obj.search_item(value);
if(search==1)
cout<<value<<" Found in LinkList!";
else if(search==0)
cout<<"ERROR:: Value NOT Found!";
}