C ++ primer Chinese Version 4th exercise 9.28

Source: Internet
Author: User

/* Here I will write down some of my answers and comments for the exercises in C ++ primer 4th (Note: I didn't buy an answer book, so it is not guaranteed that it is correct. What do you think is wrong, I hope you can tell me) the requirements for source code running are the same as those in the book. The pre-compilation and using lines are omitted. If you still don't know what to say, you can ask me, but I am also a beginner and may not know, I know that I am a beginner when I am still studying C ++ Prime. You are welcome to repost it, but please keep the author's name "jiutian Yuling ". */

 

Int main ()
{
List <char *> pclist;
Char * word1 = "I ";
Char * word2 = "am ";
Char * word3 = "";
Char * word4 = "good ";
Char * word5 = "boy ";
Pclist. push_back (word1 );
Pclist. push_back (word2 );
Pclist. push_back (word3 );
Pclist. push_back (word4 );
Pclist. push_back (word5 );
List <char *>: const_iterator pclfirst = pclist. Begin (), pcllast = pclist. End ();
Cout <"The pclist:" <Endl;
For (; pclfirst! = Pcllast; ++ pclfirst)
{
Cout <* pclfirst <"";
}
Cout <Endl;
Pclfirst = pclist. Begin ();
Vector <string> SVEC;
SVEC. Assign (pclfirst, pcllast );
Cout <"The SVEC:" <Endl;
For (vector <string >:: const_iterator first = SVEC. Begin (), last = SVEC. End ();
First! = Last; ++ first)
{
Cout <* First <"";
}
Cout <Endl;
Return 0;
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.