C++ helper function
<p>I have lots of code like this:</p>

<pre><code>otherString1 = myString1.replace("a", "b").replace("c", "d").replace("e", "f");
otherString2 = myString2.replace("a", "b").replace("c", "d").replace("e", "f");
otherString3 = myString3.replace("a", "b").replace("c", "d").replace("e", "f");
</code></pre>

<p>I would like to not repeat those <code>replace</code> methods again and again. What is the right approach to re-factoring of such code? I'm new to C++...</p>

<p>I thought I could do:</p>

<pre><code>#define REPLACE .replace("a", "b").replace("c", "d").replace("e", "f")
otherString1 = myString1#REPLACE;
</code></pre>

<p>but this does not work.</p>

<p>I obviously cannot monkey-patch the string class to add <code>myReplace()</code>...</p>

<p>What to do? And should I put the replacement code into header or the sourse file? What about those <code>static</code>, <code>inline</code>, <code>const</code> things? Should I create a whole helper class and a helper method or should I create just a function somewhere? What about something like:</p>

<pre><code>[helper.hpp]
static inline const myReplace(const StringClass s);

[helper.cpp]
static inline const myReplace(const StringClass s) {
    return s.replace("a", "b").replace("c", "d").replace("e", "f");
}

[somefile.cpp]
include "helper.hpp"
otherString3 = myReplace(myString3);
</code></pre>
