-3
我有一個小問題。我必須寫一個函數,我不知道如何。 我嘗試了一切。C++快速查找結構
#include <iostream>
#include <stdlib.h>
#include <string>
#include <list>
#include <algorithm>
using namespace std;
struct sBase
{
string NAME;
string AGE;
};
list <sBase> FIND_NAME(list <sBase> &MYLIST_ONE, const string Name, bool PART)
{
list <sBase> NEW;
list <sBase>::iterator SOLUTION = find(MYLIST_ONE.begin(), MYLIST_ONE.end(), Name); // FULL OF ERRORS . I NEED HELP HERE
NEW.push_back(*SOLUION);
return NEW;
}
int main()
{
list <sBase> MYLIST_ONE;//List including people. I used another function that add people to this.
string Name
cout << "Type a name : ";
getline(cin, Name);
string ASK;
bool PART;
string yes = "YES", no = "NO";
cout << "Is name only a part of a text ?(YES OR NO) :";
getline(cin, ASK);
if (ASK = yes)
PART = true;
if (ASK = no)
PART = false;
list <sBase> MYLIST_ONE = FIND_NAME(list <sBase> &MYLIST, const string Name, bool PART) //FUCTON SHOULD RETURN A NEW LIST INCLUDING ONLY STRUCTURE OF THIS ONE PEARSON
system("pause");
return 0;
}
IF部分是真的,那意味着它僅僅是文本。例如片段我把約翰,PART true,所以結果可以Johnaka alaka,或約翰花。如果你能幫助我,我將不勝感激。