Find any errors in the following and explain how to correct them:
a) ```
std::cout << s.data() << std::endl; // s is "hello"
```
b) ```
erase( s.rfind( "x" ), 1 ); // s is "xenon"
```
c) ```
string& foo()
{
string s( "Hello" );
... // other statements
return;
} // end function foo
```
a) The array returned by data is not null terminated.
b) Function erase is a string class member function (i.e., erase must be called by an object of type string).
c) A value is not being returned from the function (i.e., the return statement should be return s;). The return type should be string not string&—reference returns are dangerous.
You might also like to view...
Identify the compiler errors and state what is wrong with the code.
```
#include
To see and switch between open apps, on the taskbar click the ________ button
A) Task View B) Current View C) Live View D) Start Menu
How could you share a newsletter with all the members of your business fraternitywithoutprinting?
What will be an ideal response?
A Boolean variable is initialized to the valueTrueif no initial value is stated when the variable is declared.
Answer the following statement true (T) or false (F)