What will be the output of the following C++ code? [code] #include <iostream> #include <string> using namespace std; int main () { string

Thanh Hoan

New member
What will be the output of the following C++ code?
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
  string str = "123hoidap!";
  cout<<str.capacity();
  cout<<str.size();
  return 0;
}
A. 1511
B. 1111
C. 1115
D. 010
 
Answer: a
Explanation: Capacity of a string object is defined as the length of string plus the extra space given to that object which will be used further if string is expanded.
 

Tìm kiếm

Back
Top