Home > Back-end >  Map the iterator of the second value is a custom class that how to get to a public function by call
Map the iterator of the second value is a custom class that how to get to a public function by call

Time:09-26

Questions such as items, want to watch to create and query
Want to ask next how change to achieve
The code is as follows:
#include
#include
#include
#include
#include
#include
using namespace std;
The class table_item
{
int num;
Int a, [8].
Public:
Table_item ()
{

Num=0;
}
Table_item (int n, int * p)
{

Num=n;
For (int I=0; I & lt; 8; I++ p++)
A [I]=* p;
}
Table_item (table_item & amp; Y)
{

Num=y.n um.
Memcpy (a, y.a, 32);
}

Void the display ()
{
Cout & lt; <"Num:" & lt; For (int I=0; I & lt; 8; I++)
Cout & lt; Cout & lt; <"\ n";
}

};

Int main ()
{
MapCout & lt; <"Please type you want to enter the number of" & lt; int n; Cin & gt;> n;
int i;
Cout & lt; <"Please input your name, student number, number of English materialized living history record, with a space interval" & lt; For (I=0; I & lt; n; I++)
{
String x;
Cin & gt;> x;
Int no;
Cin & gt;> No;
Int b [8];
For (int j=0; J & lt; 8; J++)
Cin & gt;> B [j];
Int * q=b;
Table_item sample (no, q);
Namelist [x]=sample;
}
Cout & lt; <"Your data in the database successfully!" Cout & lt; <"Please enter your name: the students who want to find" & lt; String search;
Cin & gt;> The search;
MapBool samename (string x);

It=find_if (namelist. The begin (), namelist. The end (), samename (search));
If (it==namelist. End ()) cout & lt; <"Not in the database you want to find the information & lt; The else
{
Cout & lt; <"Name:" & lt; ((* it). The second). The display ();
}
}
Bool samename (string x, iterator it)
{
Return it - & gt; The first==x;
}

CodePudding user response:

Other place also is a little small fault, correct

CodePudding user response:

No one

CodePudding user response:

You can define an iterator it it - & gt; Second, the display

CodePudding user response:

MapIter - & gt; Second, the display ();
  • Related