std::string Concatenation & Methods

🟡 Intermediate

📖 Definition

std::string supports overloaded + and += concatenation operators, length inspection via .length() / .size(), character access via .at(i), and conversion to C-string via .c_str().

💡 Code Example

#include <iostream>
#include <string>

int main() {
    std::string s1 = "Modern ";
    std::string s2 = "C++";
    std::string full = s1 + s2;

    std::cout << "Full: " << full << " (Length: " << full.length() << ")\n";
    return 0;
}