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


C++ AddressBook::functionA方法代码示例

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


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

示例1: DETAILED


//.........这里部分代码省略.........
            i=1; //Thus bringing i back to 1 is needed to check for all invalid contacts in the new vector size.
        }
    }



/////////////////////
//MAIN OPTION BLOCK//
/////////////////////
 string option;
 //option is the variable for the menu option input from the user
 do{ //this do loop will run wile the option is not Q or q for quit.
    do{ //this do loop will run until a valid option is received from the user.
        displayMenu();
        cout << "Select an option:";
        cin >> option;
        //if the option is longer than 1 character. (can probably leave out >1 as function checks for length also)
        if(checkOption(option)==false || option.length()>1)
        {
            cout << "Invalid choice please try again.." << endl; //output invalid choice statement.
        }
    }while(checkOption(option)==false);

    //Program will get here only if option is valid.
    //Options are listed in order shown on project 3 description

        //////////////////////////////
        //OPTION [A] - Add a contact//
        //////////////////////////////
    if(option=="A" || option=="a")
    {
        //Function A uses push_back to add the new contact
        //Check AddressBook header/source file for more detail.
        bookOne.functionA();

        //if the new added push_back vector is valid (NOTE* if valid this function will NOT delete)
        if(bookOne.contactValidate(bookOne.vectorSize()-1)==1)
        {
            //Thus print detail should print the last entry added which is vector size-1;
            bookOne.printDetail(bookOne.vectorSize()-1);
            cout << "\n**New contact added to the end of the list at position " << bookOne.vectorSize()-1 << endl;
        }

        else //no need to call function again as the first if statement already called it and will delete if it's invalid.
        {    //will enter this else if it's deleted, in that case output the error message below.
            cout <<"\nInvalid contact..."
                 <<"\nPlease input valid/non space leading values for the first four fields." << endl;
        }
    }

        //////////////////////////////////////////
        //OPTION [D] - Display by sorted contact//
        //////////////////////////////////////////
    else if(option=="D" || option=="d")
    {
        //sort is the token # which it needs to be sorted by. (1-4 only)
        int sort=0;

        //do-while loop will run until a valid token choice is given.
        do{
            cout << "\nWhich field would you like to sort by?"
                << "\n1)Last Name"
                << "\n2)First Name"
                << "\n3)Nickname"
                << "\n4)Email 1"
                << "\n--------------"
开发者ID:helloye,项目名称:HunterCSCI,代码行数:67,代码来源:paing_main.cpp


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