📄 app1.html
字号:
<HTML><HEAD> <TITLE>Appendix A: Quick reference for AP classes</TITLE> <LINK REL="STYLESHEET" HREF="downey.css" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/downey.css"></HEAD><BODY><H2>Appendix A</H2><H1>Quick Reference for AP classes</H1><P>These class definitions are copied from the College Boardweb page,</P><P><A HREF="javascript:if(confirm('http://www.collegeboard.org/ap/computer-science/html/quick_ref.htm \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.collegeboard.org/ap/computer-science/html/quick_ref.htm'" tppabs="http://www.collegeboard.org/ap/computer-science/html/quick_ref.htm">http://www.collegeboard.org/ap/computer-science/html/quick_ref.htm</A></P><P>with minor formatting changes. This is probably a good time to repeat the following text, also from the College Board web page.</P><BLOCKQUOTE>Inclusion of the C++ classes defined for use in the Advanced Placement Computer Science courses does not constitute endorsement of the other material in this textbook by the College Board, Educational Testing service, or the AP Computer Science Development Committee. The versions of the C++ classes defined for use in the AP Computer Science courses included in this textbook were accurate as of 20 July 1999. Revisions to the classes may have been made sincethat time.</BLOCKQUOTE><BR><BR><H3>A.1 <TT>apstring</TT></H3><PRE>extern const int npos; // used to indicate not a position in the string// public member functions // constructors/destructor apstring(); // construct empty string "" apstring(const char * s); // construct from string literal apstring(const apstring & str); // copy constructor ~apstring(); // destructor // assignment const apstring & operator= (const apstring & str); // assign str const apstring & operator= (const char * s); // assign s const apstring & operator= (char ch); // assign ch // accessors int length() const; // number of chars int find(const apstring & str) const; // index of first occurrence of str int find(char ch) const; // index of first occurrence of ch apstring substr(int pos, int len) const; // substring of len chars, // starting at pos const char * c_str() const; // explicit conversion to char * // indexing char operator[ ](int k) const; // range-checked indexing char & operator[ ](int k); // range-checked indexing // modifiers const apstring & operator+= (const apstring & str); // append str const apstring & operator+= (char ch); // append char // The following free (non-member) functions operate on strings // I/O functions ostream & operator<< ( ostream & os, const apstring & str ); istream & operator>> ( istream & is, apstring & str ); istream & getline( istream & is, apstring & str ); // comparison operators bool operator== ( const apstring & lhs, const apstring & rhs ); bool operator!= ( const apstring & lhs, const apstring & rhs ); bool operator< ( const apstring & lhs, const apstring & rhs ); bool operator<= ( const apstring & lhs, const apstring & rhs ); bool operator> ( const apstring & lhs, const apstring & rhs ); bool operator>= ( const apstring & lhs, const apstring & rhs ); // concatenation operator + apstring operator+ ( const apstring & lhs, const apstring & rhs ); apstring operator+ ( char ch, const apstring & str ); apstring operator+ ( const apstring & str, char ch );</PRE><BR><BR><H3>A.2 <TT>apvector</TT></H3><PRE>template <class itemType>class apvector// public member functions // constructors/destructor apvector(); // default constructor (size==0) apvector(int size); // initial size of vector is size apvector(int size, const itemType & fillValue); // all entries == fillValue apvector(const apvector & vec); // copy constructor ~apvector(); // destructor // assignment const apvector & operator= (const apvector & vec); // accessors int length() const; // capacity of vector // indexing // indexing with range checking itemType & operator[ ](int index); const itemType & operator[ ](int index) const; // modifiers void resize(int newSize); // change size dynamically //can result in losing values</PRE><BR><BR><H3>A.3 <TT>apmatrix</TT></H3><PRE>template <class itemType>class apmatrix// public member functions // constructors/destructor apmatrix(); // default size is 0 x 0 apmatrix(int rows, int cols); // size is rows x cols apmatrix(int rows, int cols, const itemType & fillValue); // all entries == fillValue apmatrix(const apmatrix & mat); // copy constructor ~apmatrix( ); // destructor // assignment const apmatrix & operator = (const apmatrix & rhs); // accessors int numrows() const; // number of rows int numcols() const; // number of columns // indexing // range-checked indexing const apvector<itemType> & operator[ ](int k) const; apvector<itemType> & operator[ ](int k); // modifiers void resize(int newRows, int newCols); // resizes matrix to newRows x newCols // (can result in losing values)</PRE></BODY></HTML><BR><DIV CLASS=navigation><HR> <TABLE ALIGN=center WIDTH="100%" CELLPADDING=0 CELLSPACING=2> <TR> <TD> <IMG WIDTH=32 HEIGHT=32 ALIGN=bottom BORDER=0 ALT="" SRC="images/blank.gif" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/images/blank.gif"> </TD> <TD><A HREF="index.html" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/index.html"> <IMG WIDTH=32 HEIGHT=32 ALIGN=bottom BORDER=0 ALT="up" SRC="images/up.gif" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/images/up.gif"></A> </TD> <TD><A HREF="chapter15.html" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/chapter15.html"> <IMG WIDTH=32 HEIGHT=32 ALIGN=bottom BORDER=0 ALT="previous" SRC="images/previous.gif" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/images/previous.gif"></A> </TD> <TD ALIGN=center BGCOLOR="#99CCFF" WIDTH="100%"> <B CLASS=title>How to Think Like a Computer Scientist: Appendix A</B> </TD> <TD><A HREF="index.html" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/index.html"> <IMG WIDTH=32 HEIGHT=32 ALIGN=bottom BORDER=0 ALT="contents" SRC="images/contents.gif" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/images/contents.gif"></A> </TD> <TD> <IMG WIDTH=32 HEIGHT=32 ALIGN=bottom BORDER=0 ALT="" SRC="images/blank.gif" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/images/blank.gif"> </TD> <TD> <IMG WIDTH=32 HEIGHT=32 ALIGN=bottom BORDER=0 ALT="" SRC="images/blank.gif" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/images/blank.gif"> </TD> </TR> </TABLE> <B CLASS=navlabel>Up:</B> <SPAN CLASS=sectref><A HREF="index.html" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/index.html">Index</A></SPAN> <B CLASS=navlabel>Previous:</B> <SPAN CLASS=sectref><A HREF="chapter15.html" tppabs="http://rocky.wellesley.edu/downey/ost/thinkCS/c++_html/chapter15.html">Chapter 15</A></SPAN> <HR></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -