C++ examples for Data Type:const
Ensuring That a Function Doesn't Modify an Argument
#include <iostream> #include <string> void concat(const std::string& s1, const std::string& s2, std::string& out) { out = s1 + s2;/*ww w.ja va 2 s . co m*/ } int main() { std::string s1 = "test "; std::string s2 = "defg"; std::string s3; concat(s1, s2, s3); std::cout << "s1 = " << s1 << '\n'; std::cout << "s2 = " << s2 << '\n'; std::cout << "s3 = " << s3 << '\n'; }