example2_function_parameters.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>

void modifyString(std::string& str) {
    str += " World!";
}

int main() {
    std::string message = "Hello";
    
    std::cout << "Before function call: " << message << std::endl;
    
    modifyString(message);
    
    std::cout << "After function call: " << message << std::endl;

    return 0;
}
Back to reference