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


C++ List::Add_End方法代码示例

本文整理汇总了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;
}
开发者ID:rikhily,项目名称:LearningToCode,代码行数:71,代码来源:LinkedList.cpp


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