Function Parameter, and Function Parameter Constant
anyone can tell me different about this code : #include <iostream> #include <string> using namespace std; string upc(string nn){ string tmp; for(size_t i = 0; i < nn.length(); i++){ tmp += toupper(nn[i]); } return tmp; } int main(){ string nama = "program c++"; cout << "Nama : " << nama << endl; cout << "upperCase : " << upc(nama) << endl; string *nn = &nama; *nn = "change program c++"; cout << "Pointer : " << upc(*nn) << endl; return 0; } ======================================================================== #include <iostream> #include <string> using namespace std; string upc(const string nn){ string tmp; for(size_t i = 0; i < nn.length(); i++){ tmp += toupper(nn[i]); } return tmp; } int main(){ string nama = "program c++"; cout << "Nama : " << nama << endl; cout << "upperCase : " << upc(nama) << endl; string *nn = &nama; *nn = "change program c++"; cout << "Pointer : " << upc(*nn) << endl; return 0; }