Study your flashcards anywhere!

Download the official Cram app for free >

  • Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/29

Click to flip

29 Cards in this Set

  • Front
  • Back

assign


basic_string &assign(const basic_string &str);


basic_string *assign(const char *str);


basic_string &assign(const char *str, size_type num);


basic_string &assign(const basic_string &str, size_type index, size_type len


basic_string &assign(size_type num, char ch);

at


reference at(size_type index);

The at() function returns a reference to the character at location index. If index is not within the string, then at() reports an out of range error by throwing an object of the out_of_range class. For example, this code:


string text="ABCDEF";


char ch=text.at(2);


displays the character 'C'.

begin


iterator begin();

The begin() function returns an iterator to the first element of the current string.

c_str


const char *c_str();

The function c_str() returns a pointer to a regular C string, identical to the current string.

capacity


size_type capacity();

The capacity() function returns the number of characters that the current string can hold before it will need to allocate more memory. This number will be at least as large as size().

compare


int compare( const basic_string &str);


int compare(const char*str);


int compare(size_type index, size_type length, const basic_string &str, size_size_type length2);


int compare(size_type index, size_type length, const char *str, size_type len)

copy


size_type copy(char *str, size_type num, size_type index);

The copy() function copies num characters of the current string (starting at index)into str. The return value is the number of characters copied.

data


const char *data();

The function data() returns a pointer to the first character in the current string.

empty


bool empty();

The empty() function returns true if the current string is empty, and false otherwise.

end


iterator end();

The end() function returns an iterator to the end of the string.

erase


iterator erase(iterator pos);


iterator erase(iterator start, iterator end);


basic_string &erase(size_type index=0, size_type num = npos);

The erase() function either:


-removes the character pointed to by pos, returning an iterator to the next character,


-removes the characters between start and end, returning an iterator to the character after the last character removed,


-or removes num characters from the current string, starting at index, and returns *this.

find


size_type find(const basic_string &str, size_type index);


size_type find(const char *str, size_type index);


size_type find(const char *str, size_type index, size_type length);


size_type find(char ch, size_type index);

The function find() either:


-returns the first occurrence of str within the current string, starting at index, string::npos if nothing is found,


-returns the first occurrence of str within the current string and within length characters, starting at index, string::npos if nothing is found,


-or returns the index of the first occurrence ch within the current string, starting at index, string::npos if nothing is found.

find_first_of


size_type find_first_of(const basic_string &str, size_type index=0);


size_type find_first_of(const char *str, size_type index=0);


size_type find first_of(const *str, size_type index_size_type num);


size_type find_first_of(char ch, size_type index=0);

The find_fist of() function either:


-returns the index of the first character within the current string that matches any character in str, beginning the search at index, string::npos if nothing is found


-returns the index of the first character within the current string that matches any character in str, beginning the search at index and searching at most num characters string::npos if nothing is found,


-or returns the index of the first occurrence of ch in the current string, starting the search at index, string::npos if nothing is found.

find_first_not_of


size_type find_first_not_of(const basic_string &str, size_type index=0);


size_type find_first_not_of(const char *str, size_type index=0);


size_type find_first_not_of(const char *str, size_type index, size_type num);


size_type find_first_not_of(char ch, size_type index=0);

The find_first_not_of() function either:


-returns the index of the first character within the current string that does no match any character in str, beginning the search at index, string::npos if nothing is found,


-returns the index of the first character within the current string that does not match any character in str, beginning the search at index and searching at most num characters, string::npos if nothing is found,


-or returns the index of the first occurrence of a character that does no match ch in the current string, starting the search at index, string::npos if nothing is found.

find_last_of


size_type find_last_of(const basic_string &str, size_type index=npos);


size_type find_last_of(const char *str, size_type index=npos);


size_type find_last_of(const char *str, size_type index, size_type num);


size_type find_last_of(char ch, size_type index=npos);

The find_last_of() function either:


-returns the index of the last character within the current string that matches any character in str, beginning the search at index, string::npos if nothing is found,


-returns the index of the last character within the current string that mathes any character in str, beginning the search at index and searching at most num characters, string::npos if nothing is found,


-or returns the index of the last occurrence of ch in the current string, starting the search at index, string::npos if nothing is found.


find_last_not_of


size_type find_last_not_of(const basic_string *str, size_type index=npos);


size_type find_last_not_of(const char *str, size_type index, size_type num);


size_type find_last_not_of(char ch, size_type index= npos);

The find_last_not_of() function either:


-returns the index of the last character within the current string that does not match any character in str, beginning the search at index, string::npos if nothing is found,


-returns the index of the last character within the current string that does not match any character in str, beginning the search at index and searching at most num characters, string::npos if nothing is found


-or returns the index of the last occurrence of a character that does not match ch in the current string, string the search at index, string::npos if nothing is found.


get_allocator


allocator_type getallocator();

The function get_allocator() returns the allocator for the current string.

insert


iterator insert(iterator i, const char &ch);


basic_string &insert(size_type index, const basic_string&str);


basic_string &insert(size_type index1, const basic_string &string &str, size_type index


basic_string &insert(size_type index, const char *str, size_type num);


basic_string &insert(size_type index, size_type num, char ch);


void insert(iterator i, iterator start, iterator end);

The very multi-purpose insert() function either:


-inserts ch before the character denoted by i


-inserts str into the current string, at location index,


-inserts a substring of str(starting at index2 and num character long) into the current string, at location index1


-inserts num character of str into the current string, at location index,


-inserts num copies of ch into the current string, before the character denoted by i,


-or inserts the characters denoted by start and end into the current string, before the character specified by i.

length


size_type length();


The function length() returns the length of the current string. This number should be the same as the one returned from size().

max_size


size_type max_size();

The max_size() function returns the maximum number of characters that the string can hold.

rbegin


const reverse_iterator rbegin();

The function rbegin() returns a reverse iterator to the end of the current string.

rend


const reverse_iterator rend();


The rend() function returns a reverse iterator to the start of the current string.

replace


basic_string &replace( size_type index, size_type num, const basic_string &str ); basic_string &replace( size_type index1, size_type num1, const basic_string &str, size_type index2, size_type num2 ); basic_string &replace( size_type index, size_type num, const char *str ); basic_string &replace( size_type index, size_type num1, const char *str, size_type num2 ); basic_string &replace( size_type index, size_type num1, size_type num2, char ch ); basic_string &replace( iterator start, iterator end, const basic_string &str ); basic_string &replace( iterator start, iterator end, const char *str ); basic_string &replace( iterator start, iterator end, const char *str, size_type num ); basic_string &replace( iterator start, iterator end, size_type num, char ch );

The function replace() either:


-replaces character of the current string with up to num character from str, beginning hat index,


-replaces up to num1 characters of the current string(starting at index1) with up to num2 characters from str beginning at index2,


-replaces up to num characters of the current string with characters from str, beginning at index in str,


-replaces up to num1 character in the current string(beginning at index1) with num2 characters from str beginning at index2


-replaces up to num1 characters in the current string(beginning at index)with num2 copies of ch,


-replaces the characters in the current string from start to end with str,


-replaces characters in the current string from start to end with num characters from str,


-or replaces the characters in the current string from start to end with num copies of ch.

reserve


void reserve(size_type num);

The function reserve() sets the capacity() of the current string to at least num.


resize


void resize(size_type num);


void resize(size_type num, char ch);

The resize() function changes the size of the current string to num, optionally padding any new space with copies of ch.

rfind


size_type rfind(const basic_string &str, size_type index);


size_type rfind(const char *str, size_type index);


size_type rfind(const char *str, size_type index, size_type num);


size_type rind(char ch, size_type index);

The rfind() function either:


-returns the location of the last occurrence of str in the current string, starting at index, string::npos if nothing is found


-returns the location of the last occurrence of str in the current string, starting at index, searching at most num characters, string::npos if nothing is found


-or returns the location of the last occurrence of ch in the current string, starting at index, string::npos if nothing is found.

size


size_type size();

The size() function returns the number of characters currently in the string.

substr


basic_string substr(size_type index, size_type num=npos);

The substr() function returns a substring of the current string, starting at index, and num characters long. If num is omitted, it will default to string::npos, and the substr() function will simply return the remainder of the string starting at index. for example:


strings("What we have here is a failure to communicate:);


string sub=s.substr(21);


cout<<"the original string is"<<s<<end1;


cout<<"the substring is"<<sub<<end1;

swap


void swap(basic_string &str);

The function swap() switches str with the current string. For example:


-string first("This comes first");


-string second("And this is second");


first.swap(second);


cout<<first<<end1;


cout<<second<<end1;