C++ Function Parameter with a const Reference

Description

C++ Function Parameter with a const Reference

#include <iostream>

using namespace std;

string myFunction(const string *realmessage)
{
  string NewString = *realmessage;// ww  w.j  a va2s.  c  o  m
  NewString[6] = 'i';
  NewString.replace(9, 1, "");
  NewString.insert(18, "ad");
  NewString.replace(15, 2, "in");
  NewString.replace(23, 7, "!");
  NewString.replace(4, 3, "ali");

  return NewString;
}

int main()
{
  string message = "this is a test from java2s.com";
  cout << message << endl;

  string NewMessage = myFunction(&message);
  cout << NewMessage << endl;

  return 0;
}



PreviousNext

Related