Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
int main( )
6.
{
7.
try
8.
{
9.
string strg1("Test");
10.
string strg2("ing");
11.
strg1.append(strg2, 4, 2);
12.
cout
Options:
A .  out of range
B .  bad type_id
C .  bad allocation
D .  none of the mentioned
Answer: Option A

As we are using out of bound value on strings, So it arising an exception.
Output:
$ g++ exs2.cpp
$ a.out
Caught: basic_string::append
Type: St12out_of_range
#include 



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers