std::string handles its own memory: text can grow, shrink, join and compare — no manual bookkeeping.
1 std::string
The C++ text type — bring it in with #include <string> and it manages itself.
2 + glues text
"foot" + "ball" makes "football" — spaces are characters too.
3 .length()
Counts the characters: "Ada".length() is 3.
4 Indexing
s[0] is the first character; the last is s[s.length() - 1].
5 Compare with ==
Two strings are equal only if every character matches, in order.
Text as a first-class type
std::string1The C++ text type — bring it in with #include <string> and it manages itself. + glues text2"foot" + "ball" makes "football" — spaces are characters too. .length()3Counts the characters: "Ada".length() is 3.
Indexing4s[0] is the first character; the last is s[s.length() - 1].
Compare with ==5Two strings are equal only if every character matches, in order.
5 building blocks make up Text as a first-class type
Press Run to walk the five operations that build and print one full name.
Press play — two names become one, then the string reports its length and first character.
preprocessThe preprocessor pastes in iostream for cout.
Memory
no variables yet — press play
Console
output appears as the program runs…
Click a tool, then click the job it does.
5 conceptsTap a card to expand ?s.length()drops into place
?s[0]drops into place
?s1 + s2drops into place
?s1 == s2drops into place
?#include <string>drops into place
Concatenate, count, index — one small program, three answers.
Your predicted output — one line per console line
Hint: + joins "data" and "base" with no space. Count the characters: d-a-t-a-b-a-s-e. Index 2 is the third character.
01std::string manages its own memory — no size planning, no manual cleanup.
02+ concatenates, .length() counts, [i] reads character i (from 0).
03== compares content, not addresses — "Ada" == "Ada" is true.
04Text in quotes is characters: "A" + "B" is "AB", not addition.