subject

C++ A class BCheckString that is derived from the C++ Standard Library string class performs bounds checking and throws an exception. The BCheckString class will have two member functions:
1) A BCheckString(string s) constructor that receives a string object passed by value and passes it on to the base class constructor. It just calls the base class constructor using its constructor initialization list.
2) A overloaded operator function, char operator[ ](int k), throws an exception, a BoundsException object (i. e., StrExcept()) if its parameter, k is out bounds (i. e., negative or greater than or equal to the length of the string), otherwise it will return the character at position k in the string with calling operator [] in the string base class.
main function that attempts to access characters that are within and outside the bounds of a suitably initialized BCheckString objects
#include
#include
using namespace std;
class StrExcept { }; //String Out of Bounds Exception
// COMPLETE
class BCheckString
{
public:
};

int main()
{
//Explain program to user
cout << "This program demonstrates bounds checking on string object.";
//Get string from user and create boundCheck string object
cout << "\nEnter a string: ";
string str;
getline(cin, str);
BCheckString h(str);
//Let user access characters at specified positions in the string
//COMPLETE
cout << "Legitimate string positions are: " << 0 << ".." << h. length() -1 << endl;
for (int k = 1; k <= 5; k++)
{
cout << "Enter an integer describing a position inside or outside the string: ";
int pos;
cin >> pos;
cout << "The character at position " << pos << " is " << h[pos] << endl;
}
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
question
Computers and Technology, 23.06.2019 20:10
Leo is a recruitment executive for a large company. he has identified new labor resource requirements in both the marketing and production departments. what should be his first step in recruiting candidates for the positions? a. conduct background checks of candidates b. make job offers c. arrange interviews d. conduct reference checks e. place job ads on job sites
Answers: 1
You know the right answer?
C++ A class BCheckString that is derived from the C++ Standard Library string class performs bounds...
Questions
Questions on the website: 13722367