| Read, use, and modify classes | Design and implement
classes | APCS-A students read class declarations, write client
programs, add/modify member functions |
| Read and use constructors, including initializer lists. |
Implement constructors, copy constructors, destructor. |
Constructors should use initializer lists as opposed to assignments to
data because sometimes initializers are required, so use them for
uniformity. |
| Differentiate between public and private. | |
No public data are used in classes. Since inheritance is not part of
APCS, there is no reason to use protected functions/data. |
| Implement overloaded functions, use overloaded operators. |
Implement overloaded operators, including operator = and operator
<< (but friend not used) | Students will NOT be tested on
recognizing that functions differing in return type only are overloaded
incorrectly. |
| Use const member functions | Recognize when to make a
member function const and implement const member functions. |
|
| Use AP string class | | The AP string class is
a limited, safe subset of the standard string class. |
| Use templated AP vector and matrix classes. | Use and
re-implement AP stack and queue classes. | |
| Design and implement templated classes and
functions. | |
| Differentiate interface and implementation od class (.h and .cpp
file) | | C++ permits the ideas to be treated
seperately. |
| Use and implement structs, use construnctors in structs when
appropriate. | Implement linked lists and trees using
structs. | A struct is a class in which all data is public.
Constructors facilitate creation of structs with new, e.g., temp = new
Node(53, temp) adds a node after temp. |
| Properties of Language | |
| Understand short circut evaluation. | |
Boolean expressions such as (a && b) are evaluated
left-to-right; expression evaluation stops when the value of the entire
expression can be determined. This means that expressions such as while
(k < n && a[k] != key)can be used safely. |
| Use built in types; int, char, double, bool. | |
For compilers that do not uyse 32-bit integers long int may be used,
otherwise no modifiers short, long, signed, unsigned. |
| Use arithmetic operators +, -, *, /, %, increment decrement
operators ++, --, logical operators &&, ||, !, relational operators ==,
<, >, !=, <=, >=, =, +=, -=, *=, %=, /=, indexing operator [],
and insertion extraction for I/O <<, >> | |
Use ++ and -- only as shorthand for +=1 and -=1; do not use these
operators in expressions such as a[k++] = 0 |
| Use break. | | Used in switch statements, can
be used for loops. The continue statement will not be tested. |
| Use function syntax for typecasts e.g., cout <<
double(x)/3 | | For some types, e.g. Long int, another
form of cast is necessary: (long int) x. When compilers support the
static_cast operator it will be useful. |
| Use pointers: operators *, ->, new, delete, NULL
preferred to 0; use == and != with pointers. | The address of
operator & is used to test for aliasing in operator =, but not used
elsewhere. Pointer arithmetic, ponters to functions and pointer comparison
will NOT be tested. |
| Use [], [] in matrix class for indexing. | |
Reinforce vector of vectors and mimic notation for built-in arrays. |
| Use #include and #ifndef idiom in header files. | |
No other use of preprocessor; const variables used instead of
define. |
| Use assert. | | An AP supplied function
apassert() can be used in place of the standard function assert(). The AP
function will take a string as a parameter in addition to a Boolean
expression. It will come in two versions: one supporting exceptions and
one calling the standard function abort(). |
| Use escape sequences, \n, \t, \\, \', \" | | |
| Use value, reference, and const reference parameters. |
| |
| Recognize that values returned by operator [] for string and vector
can be assigned to, e.g., s[0] = 'a' is OK | Understand reference
return types and implications of returning reference to local
variable. | No testing of reference return types for APCS-A
students. |
|
                        | Assume input data
is "type-safe", e.g., when int expected int is read. |
| Use cin, cout, <<, >>, endl |
                        | cerr not tested,
but can be useful. |
| Use ifstream, ofstream |
                        | Students will use
open, but it will not be tested since parameters to open may be compiler
specific. |
| Use getline. |
                        | getline() is a
free function in the AP string class, consistent with the standard string
class function getline. |
| Use istream &, ostream & as formal parameters. |
  | Students should
realize that different types of streams can be passed as arguments when
formal parameter is istream &, but inheritance heirarchy of streams will
not be tested. |