Template function written for finding multimap intersectionof written one part of string as pointer and rest correctly
<p>I have written a code for finding intersection of two multimap which will compare 
values  related to key and fetch us a map containing a comman elements (combination 
of key and value) from two map. This is displaying one part of string as pointer 
and rest as usual.</p>

<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;iterator&gt;
#include &lt;stdio.h&gt;

template &lt;class InputIterator1, class InputIterator2, class OutputIterator&gt;

/* templet function to return common elements od two map  */

OutputIterator map_intersection ( InputIterator1 first1, InputIterator1 last1,
        InputIterator2 first2, InputIterator2 last2,
        OutputIterator result )
{
    while (first1!=last1 &amp;&amp; first2!=last2)
    { 
        if (*first1&lt;*first2) ++first1;
        else if (*first2&lt;*first1) ++first2;
        else {  
            const char*abc= new char[15];
            const char*def= new char[15];
            /* Below code inserts the common element in result map */ 
            if(strcmp((first1-&gt;second.c_str()),(first2-&gt;second.c_str()))==0)
            {                                                                   
                result.insert(std::pair&lt;std::string,std::string&gt;(first1-&gt;first,first1-&gt;second));
                ++first1;
                ++first2;
            }
            else
            {
                ++first1;
                ++first2;  
            } 
        } 
    }
    return result;

}

using namespace std;

int main()
{
    std::multimap&lt;string, string&gt; m;
    std::multimap&lt;string, string&gt;::iterator it2;
    std::multimap&lt;string, string&gt; intersection;
    std::multimap&lt;string, string&gt; common;
    std::multimap&lt;string, string&gt; it3;

    cout &lt;&lt;"Making Map m "&lt;&lt;endl;
    m.insert(pair&lt; string, string&gt;("1 2"," 22 3" ));
    m.insert(pair&lt; string, string&gt;("1 2"," 21 4" ));
    m.insert(pair&lt; string, string&gt;("2 1"," 31 3" ));

    cout &lt;&lt;"Making Map c "&lt;&lt;endl;
    std::multimap&lt;string, string&gt; c;
    c.insert(pair&lt; string, string&gt;("1 2"," 22 3" ));
    c.insert(pair&lt; string, string&gt;("1 2"," 22 4" ));
    c.insert(pair&lt; string, string&gt;("2 1"," 31 3" ));

    cout &lt;&lt; "Elements in common map are: " &lt;&lt; endl;
    it3=map_intersection (m.begin(), m.end(), c.begin(), c.end(),common);

    cout &lt;&lt; " am i out of the map_intersection loop " &lt;&lt; endl;
    cout &lt;&lt; " size of common map is : " &lt;&lt; it3.size()&lt;&lt; endl;
    for(it2 =it3.begin(); it2!=it3.end();it2++)
    {   
        cout &lt;&lt; "first common element is : " &lt;&lt;  
            cout &lt;&lt; it2-&gt;first &lt;&lt; " " &lt;&lt; it2-&gt;second &lt;&lt;"  " &lt;&lt; endl;
    }
    getchar();
}
</code></pre>

<p>Expected output :</p>

<pre><code>1 2   22 3
2 1   31 3 
</code></pre>

<p>Output on console:</p>

<pre><code>0x4483c41 2   22 3
0x4483c42 1   31 3
</code></pre>
