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


C++ ContactList::addToHead方法代码示例

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


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

示例1: main

int main(int argc, char** argv) {
	
const int Sentinel = 0;  //The value 0 Exits the program if entered by the user.

int input = 1; //Variable 'input' is where the value entered by the user is stored.

string name; //This value stores the name of a contact. 
//It is meant to be instantiated by the askName() function


ContactList clientList;

cout << "This program is designed to maintain contact information" << endl;


 
		while(input != Sentinel) //Loop structure. Loop will only exit when 0 is entered.
			{
				menu();          //display menu and choices
				cin >> input;    //User inputs a choice. Choice is saved in 'input'
				                 
				                 //Perform appropriate operation pending on the input value.
				if(input == 1)
					{ cout <<"(Add Contact)"<< endl;
					  clientList.addToHead(getContact());
					}
					
		   else if(input == 2)
					{ 
						if(clientList.empty())
							{ cout <<"Error:Cannot delete from empty contact list" << endl; }
					
						else
					  		{
								cout <<"(Delete Contact)" << endl;
					  			name = askName();
								if(clientList.verify(name))
								{clientList.delete_ByName(name);}
								else{ cout << "Error:Contact '" << name << "' not found in the contact list" << endl;}
							} 		
					}
					
		   else if(input == 3)
		   				if(clientList.empty())
							{ cout <<"Error:Cannot display empty contact list" << endl; }
						
						else{
							cout << "(Display all Contacts)"<< endl; 
					        clientList.displayList();
							}
					
		   else if(input == 4)
		   			
		   			if(clientList.empty())
						{ cout <<"Error:Cannot display specific contact from empty contact list" << endl; }
					
					else{
						cout <<"(Display Specific Contact)"<< endl;
					 	name = askName();
						if(clientList.verify(name))
						{clientList.get_ByName(name)->display();}
						
						else
					    {cout << "Error: Contact '" << name << "' not found in the contact list" << endl;}
					}
					
		
			}	
		
	return 0;
}
开发者ID:cPais,项目名称:ContactList,代码行数:71,代码来源:main.cpp


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