STL container list, vector, stack, bitset, set, multiset instance demo

1, list

//The two text files contain the college entrance examination results of a middle school, including the admission ticket number, name, university name, and total score information.
//However, due to some reasons, there may be duplicate records in the two files. It is now required to merge the contents of the two files together, remove the duplicate records, and arrange them in ascending order of the admission ticket number.

#include <iostream>
#include <string>
#include <list>
using namespace std;

class student
{<!-- -->
friend class stuManger;
public:
student(string m_strNum, string m_strName, string m_strSex, string m_strDate)
:m_strNum(m_strNum), m_strName(m_strName), m_strSex(m_strSex), m_strDate(m_strDate)
{<!-- -->}
student()
{<!-- -->}
~student()
{<!-- -->}
void show() const
{<!-- -->
cout <<this->m_strNum << " " <<this->m_strName
<< " " <<this->m_strSex << " " <<this->m_strDate << endl;
}
bool operator<(student & s)
{<!-- -->
return this->m_strNum < s.m_strNum;
}
bool operator==(student & s)
{<!-- -->
return this->m_strNum == s.m_strNum;
}
private:
string m_strNum;
string m_strName;
string m_strSex;
string m_strDate;
};


class stu Mannger
{<!-- -->
public:
stuManger()
{<!-- -->}
~stuMannger()
{<!-- -->}
void AddInfo(student & stu)
{<!-- -->
this->m_lStud.push_back(stu);
}
void MergeInfo(stuMannger & SM)
{<!-- -->
this->m_lStud.sort(); //Sort, prepare for merging
SM.m_lStud.sort(); //Sorting, preparing for merging (requires overloading<)
this->m_lStud.merge(SM.m_lStud); //Merge two ordered linked lists (need to overload <)
this->m_lStud.unique(); //Remove adjacent repeated elements, keep one value (need to overload ==)
}
void ShowInfo() const
{<!-- -->
for (list<student>::const_iterator it = this->m_lStud.begin(); it != this->m_lStud.end(); it + + )
it->show();
}
private:
list<student> m_lStud;
};

int main()
{<!-- -->
student s1("101", "Zhang San", "Male", "1998-02-05");
student s2("102", "Wang Wu", "Female", "1995-12-12");
student s3("103", "High Six", "Male", "1993-11-11");
student s4("104", "Lu Da", "Male", "1991-10-06");
student s5("105", "Fat and small", "Female", "1998-08-13");
stuMannger sm1; //For example, file 1
stuMannger sm2; //for example, file 2
sm1.AddInfo(s5);
sm1.AddInfo(s3);
sm1.AddInfo(s1);
sm1.AddInfo(s2); //1 2 3 5

sm2.AddInfo(s2); //2 3 4 5
sm2. AddInfo(s3);
sm2.AddInfo(s5);
sm2. AddInfo(s4);

sm1. ShowInfo();
cout << endl;
sm2. ShowInfo();

cout << endl << "----------------After Merge-----------------" << endl;
sm1. MergeInfo(sm2);
sm1. ShowInfo();
return 0;
}

2, vector

//[1] <vector> Use vector to write a student information (student number, name, gender, date of birth) management class,
//There are adding functions, query functions (query based on the student number), display functions (completely display the query results), and compile function tests!

#include <iostream>
#include <vector>
#include <string>
using namespace std;

class stu Mannger;

//Student class
class student
{<!-- -->
friend class stuMannger; //declare the stuMannger class as a friend class of the student class, so that it can access the private members of the student class
public:
student(string m_strNum, string m_strName, string m_strSex, string m_strDate)
:m_strNum(m_strNum),m_strName(m_strName),m_strSex(m_strSex),m_strDate(m_strDate)
{<!-- -->}
student()
{<!-- -->}
~student()
{<!-- -->}
void show() const
{<!-- -->
cout <<this->m_strNum << " " <<this->m_strName
<< " " <<this->m_strSex << " " <<this->m_strDate << endl;
}
private:
string m_strNum;
string m_strName;
string m_strSex;
string m_strDate;
};

//Management class: provide interface
class stu Mannger
{<!-- -->
public:
stuManger()
{<!-- -->}
~stuMannger()
{<!-- -->}
void AddStudent(student & stu)
{<!-- -->
this->m_vStud.push_back(stu);
}
void AddStudent(student & amp; & amp; stu)
{<!-- -->
this->m_vStud.push_back(stu);
}
void ShowAll()
{<!-- -->
for (unsigned int i = 0; i < m_vStud. size(); i ++ )
this->m_vStud[i].show();
}
student* FindStudent(string & amp; & amp; num)
{<!-- -->
for (unsigned int i = 0; i < m_vStud. size(); i ++ )
{<!-- -->
if (num == m_vStud[i].m_strNum)
{<!-- -->
cout << "Ok, Find the people!" << endl;
return &m_vStud[i];
}
}
return nullptr;
}
student* FindStudent(string & num)
{<!-- -->
for (unsigned int i = 0; i < m_vStud. size(); i ++ )
{<!-- -->
if (num == m_vStud[i].m_strNum)
{<!-- -->
cout << "Ok, Find the people!" << endl;
return &m_vStud[i];
}
}
return nullptr;
}
private:
vector<student> m_vStud;
};

int main()
{<!-- -->
int sel = 0;
string num, name, sex, date;
stu Mannger SM;
while (true)
{<!-- -->
cout << "**************************" << endl;
cout << "*[1]Add studentInfo *" << endl;
cout << "*[2]Show studentInfo *" << endl;
cout << "*[3]Find studentInfo *" << endl;
cout << "*[0]Exit system *" << endl;
cout << "**************************" << endl;
cout << "Please select item:>";
cin >> sel;
if (sel == 1)
{<!-- -->
cout << "Please input the info of student:>" << endl;
cin >> num >> name >> sex >> date;
SM.AddStudent(student(num, name, sex, date));
system("cls");
}
else if (sel == 2)
{<!-- -->
SM. ShowAll();
system("pause");
system("cls");
}
else if (sel == 3)
{<!-- -->
string num;
cout << "Please input will find the people of num:>";
cin >> num;
student* pFind = SM. FindStudent(num);
if (pFind == nullptr)
cout << "Not find the people!" << endl;
else
pFind->show();
system("pause");
system("cls");
}
else if (sel == 0)
break;
}
return 0;
}

/*
int main()
{
student s1("101", "Zhang San", "Male", "1998-02-05");
student s2("102", "Wang Wu", "Female", "1995-12-12");
student s3("103", "High Six", "Male", "1993-11-11");
student s4("104", "Lu Da", "Male", "1991-10-06");
student s5("105", "Fat and small", "Female", "1998-08-13");
stu Mannger SM;
SM.AddStudent(s1);
SM. AddStudent(s2);
SM. AddStudent(s3);
SM. AddStudent(s4);
SM. AddStudent(s5);
SM. ShowAll();
cout << "----------find----------" << endl;
student* pFind = SM. FindStudent("104");
if (pFind == nullptr)
cout << "Not find the people!" << endl;
else
pFind->show();
return 0;
}
*/
#include <iostream>
#include <vector>
#include <string>
using namespace std;
/*
The basic information of the known author includes number and name;
Book information includes ISBN, title, publisher;
One author can publish many books;
Please use the collection class to reflect the above relationship!

Problem-solving ideas:
It is required that the program must be able to manage multiple authors, and each author can manage multiple books published by him, so it should be a nested class of the collection class.
The compiled functional classes are: basic information class Book, author basic information class Writer class, author collection information class WriterCollect class.

In addition: you can try to write multiple files!

*/

//
class book
{<!-- -->
public:
Book(string b_Num, string b_Name, string b_Public):
b_Num(b_Num),b_Name(b_Name),b_Public(b_Public)
{<!-- -->}
void showBook()
{<!-- -->
cout << "\t";
cout << "b_Num:" << b_Num << " "
<< "b_Name:" << b_Name << " "
<< "b_Public:" << b_Public << endl;
}
public:
string b_Num;
string b_Name;
string b_Public;
};
//
class Writer
{<!-- -->
public:
Writer(string w_Num, string w_Name):
w_Num(w_Num), w_Name(w_Name)
{<!-- -->}
void AddBook(Book & amp; book)
{<!-- -->
vBook. push_back(book);
}
void ShowWriter()
{<!-- -->
cout << "w_Num:" << w_Num << " " << "w_Name:" << w_Name << endl;
LoadBook();
}
void LoadBook()
{<!-- -->
for (int i = 0; i < vBook. size(); i ++ )
{<!-- -->
vBook[i].showBook();
}
}
public:
string w_Num;
string w_Name;
vector<Book> vBook;
};
//
class WriterCollect
{<!-- -->
public:
void AddWriter(Writer & writer)
{<!-- -->
vWriter.push_back(writer);
}
size_t WriterCount()
{<!-- -->
return vWriter. size();
}
void showAll()
{<!-- -->
for (int i = 0; i < vWriter. size(); i ++ )
{<!-- -->
vWriter.at(i).ShowWriter();
}
}
public:
vector<Writer> vWriter;
};

int main()
{<!-- -->
//First Writer:
Writer w1("101", "zhang");
Book b1("1111", "C Language", "BeiJing");
Book b2("2222", "C++ Language", "QingHai");
w1.AddBook(b1);
w1.AddBook(b2);

//Second Writer:
Writer w2("105", "wang");
Book b3("3333", "Java Language", "ShangHai");
w2.AddBook(b3);

//Manager:
Writer Collect Collect;
Collect. AddWriter(w1);
Collect. AddWriter(w2);

Collect. showAll();

return 0;
}
#include <iostream>
#include <vector>
#include <string>
using namespace std;

/*
Use vector to write a student information management class, including adding operations, searching operations, and displaying operations.
//Problem-solving idea: From the meaning of the question, there must be a basic information class, and then there must be a management class!

*/

class student
{<!-- -->
public:
student(int num, string name, string sex, string date) :
num(num), name(name), sex(sex), date(date)
{<!-- -->}
void show()
{<!-- --> cout << num << "\t" << name << "\t" << sex << "\t" << date << endl; }

public:
int num;
string name;
string sex;
string date;
};

class stuCollect
{<!-- -->
public:
void Add(student & amp; stu)
{<!-- -->
vStu.push_back(stu);
}
student* Find(int num)
{<!-- -->
int i = 0;
for (; i < vStu. size(); i ++ )
{<!-- -->
student & stud = vStu.at(i);
if (stud. num == num)
{<!-- -->
IsFind = true;
break;
}
}
if(IsFind)
return ( &vStu[i]);
return nullptr;
}
public:
vector<student> vStu;
bool IsFind = false;
};

int main()
{<!-- -->
student s1(101, "zhang", "Male", "1992");
student s2(102, "wang", "female", "1996");
student s3(103, "li", "Male", "1991");
student s4(104, "zhao", "female", "1990");
\t
stuCollect container;
container. Add(s1);
container. Add(s2);
container. Add(s3);
container. Add(s4);
student* pFind = container. Find(102);
if (pFind)
pFind->show();
else
cout << "No this person in the container!" << endl;
return 0;
}

3, stack

//Title: Write a stack class with a fixed size using <stack>!

#include <iostream>
#include <stack>
using namespace std;

template<class_Ty>
class MyStack : public stack<_Ty>
{<!-- -->
public:
MyStack(int size):m_MaxSize(size)
{<!-- -->}
void MyPush(const _Ty & v)
{<!-- -->
if (stack<_Ty>::size() < m_MaxSize)
stack<_Ty>::push(v);
else
cout << "Stack full,can not push!" << endl;
}
private:
int m_MaxSize;
};



int main()
{<!-- -->
MyStack<int> st(5);
st. MyPush(1);
st. MyPush(2);
st. MyPush(3);
st. MyPush(4);
st. MyPush(5);
st. MyPush(6);
return 0;
}
#include <iostream>
#include <deque>
#include <stack>
using namespace std;

/*
Write a fixed-size stack class!

Problem-solving ideas:
(1) The custom stack class MyStack is derived from the stack class. In this way, the MyStack class inherits the inherent characteristics of the stack.
(2) Add a unique function in the MyStack class, that is, limit the size;
Then on the one hand, define a member variable m_MaxSzie, pass in the stack size through the constructor, and assign it to m_MaxSize;
On the other hand, the push function needs to be overloaded. If the number of current stack elements is less than m_MaxSize, push new elements into the stack!
*/

template <class _T, class _Container = deque<_T>>
class MyStack : public stack<_T, _Container>
{<!-- -->
public:
MyStack(int m_MaxSize) : m_MaxSize(m_MaxSize) {<!-- -->}
void push(const _T & t)
{<!-- -->
//On the surface, the size/push function in the MyStack class is called, but in fact it is transferred to the size/push function in the base class in the end!
if(stack<_T, _Container>::size() < m_MaxSize)
{<!-- -->
stack<_T, _Container>::push(t);
}
else
{<!-- -->
cout << "stack is fill!" << endl << "elem=" << t << " is not pushed!" << endl;
}
}
private:
int m_MaxSize;
};

/*
class MyStack : public stack<int, deque<int>>
{
public:
void push(const int & t)
{
cout << "Hello World!" << endl;
stack<int, deque<int>>::push(4); //Call the member function of the base class
}
};
*/

int main()
{<!-- -->
MyStack<int, deque<int>> stack(2);
stack. push(3);
stack. push(4);
stack.push(5); //The space is full, unable to push the stack
return 0;
}
#include <iostream>
#include <string>
#include <stack>
using namespace std;


/*
Parenthesis matching problem.

Core:
(1) When the right parenthesis is read, the top element of the stack is read, and if it is the matching left parenthesis, the top element of the stack is deleted (popped);
(2) The stack is empty when it is initialized. If the parenthesis expression is completely correct, then after a series of stacking and popping, the final stack is still empty.
*/

class CExpression
{<!-- -->
public:
CExpression(string m_strExpression) : m_strExpression(m_strExpression) {<!-- --> flag = true; }
bool IsVaild()
{<!-- -->
int size = m_strExpression. size();
for (int i = 0; i < size; i ++ )
{<!-- -->
char ch = m_strExpression.at(i); //used to save expression characters one by one
if (ch == '(' || ch == '[')
Stack. push(ch);
if (ch == ')' || ch == ']')
{<!-- -->
if (Stack.empty()) //")[]",,,
{<!-- -->
flag = false; //Expression Error
break;
}
else
{<!-- -->
char ch_top = Stack. top();
if (ch_top == '(' & amp; & amp; ch == ')')
Stack. pop();
else if (ch_top == '[' & amp; & amp; ch == ']')
Stack. pop();
else //"([)",,,
{<!-- -->
flag = false;
break;
}
}
}
}
if (flag == true & amp; & amp; !Stack.empty()) //"(",,,
flag = false;
return flag;
}
private:
string m_strExpression;
bool flag; //if the expression is intitial true
stack<char> Stack;
};


int main()
{<!-- -->
CExpression str1("[)]");
CExpression str2("([]");
CExpression str3("()[");
CExpression str4("([]())");
str1.IsVaild() == true ? cout << "TRUE" << endl : cout << "FALSE" << endl;
str2.IsVaild() == true ? cout << "TRUE" << endl : cout << "FALSE" << endl;
str3.IsVaild() == true ? cout << "TRUE" << endl : cout << "FALSE" << endl;
str4.IsVaild() == true ? cout << "TRUE" << endl : cout << "FALSE" << endl;
return 0;
}

4, bitset

#include <iostream>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

/*
Compilation of functional class statistics on the number of days of attendance of students per month.
\t
Problem-solving ideas: If every month is calculated as 31 days, there are two states of student attendance, either attendance or absence;
Therefore, it is the most space-saving to use the bitset bit vector to describe. The status of 31 days per month only uses 31 bits, and the description can be clearly described in less than 4 bytes!
*/

//
class MyAttend
{<!-- -->
public:
MyAttend(int month,string strAttend):month(month),b(strAttend){<!-- -->}
int GetMonth() {<!-- --> return this->month; }
int GetAttendDays() {<!-- --> return this->b.count(); }
public:
int month;
bitset<31>b;
};

//
class student
{<!-- -->
public:
student(string name):name(name){<!-- -->}
void AddAttend(MyAttend & amp; attend) {<!-- --> v.push_back(attend); }
void ShowAttendDays()
{<!-- -->
cout << "Name:" << name << endl;
cout << "month" << "\t" << "Attend Days" << endl;;
for (int i = 0; i < v. size(); i ++ )
{<!-- -->
MyAttend Attend = v.at(i);
int month = Attend. GetMonth();
int days = Attend. GetAttendDays();
cout << month << "\t" << days << endl;
}
}
public:
string name;
vector<MyAttend> v; //Attendance collection (attendance records of each month)
};

int main()
{<!-- -->
MyAttend attend1(1, string("111111111111111111111111111111")); //January attendance record
MyAttend attend2(2, string("111111111111111111111111111000"));
student stud("zhang");
stud.AddAttend(attend1); //
stud.AddAttend(attend2);
stud.ShowAttendDays();
\t
return 0;
}

5, deque

#include <iostream>
#include <deque>
using namespace std;

/*
Based on deque, write a first-in first-out queue class!

Analysis: The analysis shows that: the queue operation is FIFO, that is, tail plug deletion,
All the required functions can be said to be included in the deque,
So just use deque to complete the so-called custom queue!

In other words: our operation on the custom queue is actually done with the help of deque!
*/

template <class T>
class MyQueue
{<!-- -->
public:
void push(const T & t)
{<!-- -->
DQ.push_back(t);
}
void pop()
{<!-- -->
DQ. pop_front();
}
int size()
{<!-- -->
return DQ. size();
}
bool empty()
{<!-- -->
return DQ.empty();
}
T & front()
{<!-- -->
return (*(DQ.begin()));
}
T & back()
{<!-- -->
return (*(--DQ.end()));
//return *DQ.end()--; //End with error reporting? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
}
void show()
{<!-- -->
for (int i = 0; i < DQ. size(); i ++ )
cout << DQ.at(i) << "\t";
cout << endl;
}
public:
deque<T> DQ; //As an interface of custom queue
};

int main()
{<!-- -->
MyQueue<int> Q;
for (int i = 1; i <= 5; i ++ )
Q. push(i);
cout << "Init Queue:" << endl;
Q.show(); //1 2 3 4 5
Q. pop();
Q.show(); //2 3 4 5
Q. push(7);
Q.show(); //2 3 4 5 7
cout << Q.empty() << endl; //0
cout << Q. front() << endl; //1
cout << Q.back() << endl; //7
return 0;
}

6, set

#include <iostream>
#include <string>
#include <set>
using namespace std;

/*
Write a collection class, including the three functions of union, intersection, and difference. Duplicate data is not allowed, and use the student class to test it!
*/

//
class student
{<!-- -->
public:
student(string num, string name) :num(num), name(name) {<!-- --> }
string GetNum() {<!-- --> return this->num; }
string GetName() {<!-- --> return this->name; }
bool operator<(const student & amp; stu) const {<!-- --> return this->num < stu.num; }
friend ostream & amp; operator<< (ostream & amp; out, const student & amp; stu);
public:
string num;
string name;
};
ostream & amp; operator<< (ostream & amp; out, const student & amp; stu)
{<!-- -->
out << stu.num << "\t" << stu.name << endl;
return out;
}
//
template<class __Kty, class __Pr = less<__Kty>, class __Alloc = allocator<__Kty>>
class MySet : public set<__Kty, __Pr, __Alloc>
{<!-- -->
public:
MySet(const __Kty* first, const __Kty* last):
set<__Kty, __Pr, __Alloc>(first, last)
{<!-- -->}
~MySet()
{<!-- -->}
public:
void Union(MySet<__Kty> & set2)
{<!-- -->
typename MySet<__Kty>::iterator it = set2.begin();
while (it != set2. end())
{<!-- -->
this->insert(*it);
it + + ;
}
}
void Intersection(MySet<__Kty> & set2)
{<!-- -->
set<__Kty> temp;
typename set<__Kty>::iterator it = this->begin();
while (it != this->end())
{<!-- -->
if (set2. find(*it) != set2. end())
temp. insert(*it);
it + + ;
}
this->swap(temp);
}
void Difference(MySet<__Kty> & set2)
{<!-- -->
set<__Kty> temp;
typename set<__Kty>::iterator it = this->begin();
while (it != this->end())
{<!-- -->
if (set2. find(*it) == set2. end())
temp. insert(*it);
+ + it;
}
this->swap(temp);
}
public:
void Show()
{<!-- -->
typename set<__Kty, __Pr, __Alloc>::iterator it = this->begin();//this->set<__Kty>::begin()
while (it != this->set<__Kty>::end())//this->end()
{<!-- -->
cout << *it;
it + + ;
}
}
};

int main()
{<!-- -->
student stu1[] = {<!-- --> student("101","zhangsan"),student("102","lisi"),student("108" ,"yaoyi") };
student stu2[] = {<!-- --> student("101","zhangsan"),student("103","wangwu"),student("104" ,"zhaoliu") };
MySet<student> Set1(stu1, stu1 + sizeof(stu1) / sizeof(stu1[0]));
MySet<student> Set2(stu2, stu2 + sizeof(stu2) / sizeof(stu2[0]));

cout << "init assemble --- Set1:" << endl;
Set1. Show();
cout << "---------------------------" << endl;
cout << "init assemble --- Set2:" << endl;
Set2. Show();

cout << "--------------------------------------------- --------" << endl;

Set1. Union(Set2);
//Set1. Intersection(Set2);
//Set1. Difference(Set2);
Set1. Show();

return 0;
}

7, multiset

#include <iostream>
#include <string>
#include <set>
using namespace std;

/*
Assume that the employee attributes of the company have name and department;
Create a collection class for managing employees: (1) add employees; (2) display functions, in ascending order by department, or in ascending order by name if the departments are the same.
*/

//
class CEmployee
{<!-- -->
public:
CEmployee(string name, string depart)
{<!-- -->
this->name = name;
this->depart = depart;
}
bool operator<(const CEmployee & em) const
{<!-- -->
if (this->depart == em.depart)
return this->name < em.name;
return this->depart < em.depart;
}
void show()
{<!-- --> cout <<this->name << "\t" <<this->depart << endl; }
public:
string name;
string depart;
};

//
class CManage
{<!-- -->
public:
void Add(CEmployee & em)
{<!-- -->
Set.insert(em);
}
void showAll()
{<!-- -->
multiset<CEmployee>::iterator it = Set.begin();
while (it != Set. end())
{<!-- -->
CEmployee Obj = *it;
Obj. show();
it + + ;
}
}
public:
multiset<CEmployee> Set;
};

//
int main()
{<!-- -->
CEmployee e1("zhanSan", "Ministry of Manpower");
CEmployee e2("zhouQi", "Assembly Department");
CEmployee e3("wangWu", "Manufacturing Department");
CEmployee e4("zhaoLiu", "Manufacturing Department");
CEmployee e5("liSi", "Assembly Department");
CEmployee e6("tianJiu", "Manufacturing Department");

CManage manage;
manage.Add(e1);
manage.Add(e2);
manage. Add(e3);
manage. Add(e4);
manage.Add(e5);
manage. Add(e6);
\t
manage. showAll();
return 0;
}

8, multimap

#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <vector>
using namespace std;

/*
Write a synonym dictionary functional class, each word is followed by its synonyms, the example is as follows:
one unique single
correct true right
near close
...
*/

//
class CWord
{<!-- -->
public:
CWord(string strLine)
{<!-- -->
istringstream in(strLine); //Convert str to string stream
in >> mainWord; //The first word is the main word
string temp("");
while (!in. eof())
{<!-- -->
in >> temp;
v_nearWord.push_back(temp); //The remaining words are synonyms of the main word
}
}
string GetMainWord() {<!-- --> return mainWord; }
void show()
{<!-- -->
cout << "Main Word is: " << mainWord ;
cout << "\t===>\t" << "Near Word is: ";
for (int i = 0; i < v_nearWord. size(); i ++ )
cout << v_nearWord[i] << " ";
cout << endl;
}
public:
string mainWord;
vector<string> v_nearWord;
};
//
class CWordManage
{<!-- -->
public:
void Add(string strLine)
{<!-- -->
CWord word(strLine);
pair<string, CWord> pr(word. GetMainWord(), word);
Map.insert(pr);
}
//show near word for mainWord
void showSpecific(string mainWord)
{<!-- -->
multimap<string, CWord>::iterator it = Map.find(mainWord);
if (it != Map. end())
{<!-- -->
CWord & amp; obj = (*it).second;
obj. show();
}
else
cout << "no near word for [" << mainWord << "]" << "in this multimap!" << endl;
}
//show near word for all mainWord
void showAll()
{<!-- -->
multimap<string, CWord>::iterator it = Map.begin();
while (it != Map. end())
{<!-- -->
CWord & amp; obj = (*it).second;
obj. show();
it + + ;
}
}
public:
multimap<string, CWord> Map;
};


int main()
{<!-- -->
string s[] =
{<!-- -->
string("one single unique"),
string("correct true right"),
string("near close"),
string("happy please"),
string("strong powerful")
};
CWordManage manage;
for (int i = 0; i < sizeof(s) / sizeof(s[0]); i ++ )
manage.Add(s[i]);
cout << "-------All near word for all mainWord---------" << endl;
manage. showAll();
\t
cout << "****************specific**********************" << endl;
manage. showSpecific("correct");
manage. showSpecific("strong");
manage. showSpecific("ni");
return 0;
}