本文整理汇总了C++中List::Add_End方法的典型用法代码示例。如果您正苦于以下问题:C++ List::Add_End方法的具体用法?C++ List::Add_End怎么用?C++ List::Add_End使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List::Add_End方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
// New list
List list;
Node *answer;
// Add_End nodes to the list
list.Add_End(111);
list.Print();
list.Add_End(222);
list.Print();
list.Add_End(333);
list.Print();
list.Add_End(444);
list.Print();
list.Add_End(555);
list.Print();
cout << endl << endl;
// Delete nodes from the list
list.Delete(444);
list.Print();
// list.Delete(333);
// list.Print();
// list.Delete(222);
// list.Print();
// list.Delete(555);
// list.Print();
// list.Delete(111);
// list.Print();
// cout<<endl<<endl;
//
// cout << "Testing Add_Front: and others"<<endl;
// list.Add_Front(888);
// list.Print();
// list.Add_Front(999);
// list.Print();
// list.Add_Front(49);
// list.Print();
// cout<<endl<<endl;
// cout << "Checking find function"<<endl;
// answer = list.Find(888);
// cout<<"Value for node returned by find function call with 888 is "<<answer->Data()<<"."<<endl;
// cout<<"Checking find function"<<endl;
// answer = list.Find(999);
// cout<<"Value for node returned by find function call with 888 is "<<answer->Data()<<"."<<endl;
//
// cout<<"Checking find function"<<endl;
// answer = list.Find(49);
// cout<<"Value for node returned by find function call with 888 is "<<answer->Data()<<"."<<endl;
// cout<<"Call find function with value not in list."<<endl;
// answer = list.Find(7);
// if(answer == NULL)
// {
// cout<<"returned null pointer since 7 not found"<<endl;
//
// }
// else
// {
// cout<< "in else of answer == NULL where Value for node returned by find function call with 7 is "<<answer->Data()<<"."<<endl;
// }
//
// cout<<"testing delete_front: "<<endl;
// list.Delete_Front();
// list.Print();
// cout<<"testing delete_end: "<<endl;
//
// list.Delete_End();
// list.Print();
return 0;
}