July 2013
Intermediate to advanced
124 pages
1h 42m
English
CHAPTER 8
![]()
String
The string class in C++ is used to store string values. Before a string can be declared the string header must first be included. The standard namespace can also be included since the string class is part of that namespace.
#include <string>using namespace std;
Strings can then be declared like any other data type. To assign a string value to a string variable, delimit the literals by double quotes and assign them to the variable. The initial value can also be assigned through constructor initialization at the same time as the string is declared.
string h = "Hello";string w (" World");
String combining
The plus sign, known ...
Read now
Unlock full access