BelowProgramWhat is the output result? Why?
# Include <iostream> # include <vector> # include <set> using namespace STD; struct node {char ch; int cost; node () {CH = '\ 0 '; cost = 0;} // commented out this function, without any impact on the entire program bool operator = (const node & RHs) const {return RHS. ch = CH;} // If you annotate this program, a bunch of errors will occur, related to errors in STL, is a bool operator that cannot be debugged or modified <(const node & RHs) const {return RHS. cost> cost; }}; int main (INT argc, char * argv []) {node A, B; Multiset <node> MS; Ms. insert (a); Ms. insert (B); set <node> S; S. insert (a); S. insert (B); cout <"ms. size () = "<Ms. size () <"\ ns. size () = "<S. size () <Endl; // although we have redefined the = function, this is useless. Set only uses the <symbol to judge Ms. clear (); S. clear ();. ch = 'a'; B. ch = 'B'; S. insert (a); S. insert (B); Ms. insert (a); Ms. insert (B); cout <"ms. size () = "<Ms. size () <"\ ns. size () = "<S. size () <Endl; Ms. clear (); S. clear ();. ch = 'a'; B. ch = 'a';. cost = 2; B. cost = 1; S. insert (a); S. insert (B); Ms. insert (a); Ms. insert (B); cout <"ms. size () = "<Ms. size () <"\ ns. size () = "<S. size () <Endl; // You Can See That cout <"(* (S. begin ())). cost = "<(* (S. begin ())). cost <Endl; return 0 ;}
Test results: