#include
of the corresponding header
<>
, e.g., <string>
,
<vector>
std
namespace
::
)
::
operator appears in several other contexts as well (class scope for example)
using namespace std;
char []
or char *
) terminated with a null ('\0') character.
[]
) operator (as
well as other inPlace functions, e.g. clear
, erase
, etc)
string s = "Hello"; s[0] = 'J';
<<
operator) for all built-in types
<<
operator is defined to permit chaining of values to output
cout << "The number of values processed is " << numProcess << endl;
<<
call is the left-hand operand (cout
here) —
which is thus passed to the next <<
>>
operator.
cin >> i; // i is modified by the operator, so it is passed as a refeeence paramter
vector
[]
), appending/removal from-end (push_back
, pop_back
), as
well as general insertion, and iteration
vector
's []
operator does NOT do range checking
at
function that provides that functionality if so desired
list
map
and unordered_map
map
: TreeMap
unordered_map
: HashMap
get
/put
of Java's Map
is replaced with []
map<string, int> freqs; … cout << freqs["dog"]; // S.o.p(freqs.get("dog")) … freqs["cat"] = 0; // m.put("cat", 0);
keySet
using namespace std;
char []
) in which the string is terminated with an
ASCII 0 ('\0').
string
class also uses operator overloading which provides a more intuitive interface to the operations
(e.g. []
)