#include <iostream>
#include <string>

// Function declarations
void function1(std::string& str);
void function2(std::string& str);
void function3(std::string& str);

int main() {
    std::string myString = "Hello";
    std::cout << "Before: " << myString << std::endl;

    // Call the first function, passing the string by reference
    function1(myString);

    std::cout << "After: " << myString << std::endl;
    return 0;
}

// Function definitions
void function1(std::string& str) {
    std::cout << "In function1: " << str << std::endl;
    // Call the next function, passing the string by reference
    function2(str);
}

void function2(std::string& str) {
    std::cout << "In function2: " << str << std::endl;
    // Call the next function, passing the string by reference
    function3(str);
}

void function3(std::string& str) {
    std::cout << "In function3: " << str << std::endl;
    // Modify the string
    str += ", World!";
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: