Question: and then display just the initials. For example, if the input is John Peter Doe, the initials JPDmust be displayed. Member functions of the stringclass

and then display just the initials. For example, if the input is John Peter Doe, the initials JPDmust
be displayed.
Member functions of the stringclass to manipulate the values of stringobjects are provided on the
next page.
QUESTION 117 MARKS
COS1511
Oct/Nov 2023
9
[TURN OVER]
Function signature Description
int size() Returns the size (i.e. length) of a string object.
string substr(int,int) Returns a substring of a string object. The first parameter
specifies the starting position (i.e. the position from which
the substring should be copied) and the second parameter
specifies how long the substring should be (i.e. how many
characters should be copied). The second parameter may be
omitted, in which case the sub-string consisting of all the
characters from the starting position (specified by the first
and only parameter) to the end of the string are returned.
int find(string,int) Returns the position of a string (specified as the first
parameter) within a string object. The second parameter is
optional, and can be used to specify where the search has to
be commenced. If omitted, the search commences at the
beginning of the string object. If the string being sought is not
found, -1 is returned.
void insert(int,string) Inserts a string (specified as the second parameter) into a
string object at a particular position (specified as the first
parameter)
void erase(int,int) Erases a substring from a string object. The substring that is
to be erased is determined by the two parameters: from the
position specified by the first parameter, as many characters
as specified by the second parameter
void replace(int,int,string) Replaces specified characters of a string object with another
string. The characters to be replaced are determined by the
first two parameters: from the position specified by the first
parameter, as many characters as specified by the second
parameter. The string to be inserted in their place is specified
by the third parameter.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!