title: Calling C++ code from C using inbuilt c++ classes and templates
body: <p>So I want to use <code>string class</code> and <code>multiset template</code> of <code>C++.</code></p>
  
  <p>My original code interfaces from <code>Python</code> to <code>C</code> using <code>ctypes</code> and now I am trying to interface <code>C</code> to <code>C++</code>. (If there is any direct interfacing between <code>Python</code> &amp; <code>C++</code>, I would welcome the suggestion but scanning through a couple of Stack Overflow and Stack Exchange, I found this method to be more feasible.
  @n.m in comments provided solution to this, but I would still like to know if it is possible to interface C &amp; C++ for educational purpose)</p>
  
  <p>So here is a simple example to reproduce what happens when I try to merge with string class...</p>
  
  <pre><code>ex.c
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void cppstr(char *);
  
  void str(char *x) { 
      cppstr(x);                    
  }
  
  int main() {
      char *x;
      x = (char *)malloc(sizeof(char)*1024);
      str(x);
      return 0;
  }
  </code></pre>
  
  <p>Above is my c file.</p>
  
  <pre><code>ex.cpp
  
  #include &lt;string&gt;
  #include &lt;cstring&gt;
  using namespace std;
  extern "C" void cppstr(char *s) {
     string x = "HELLO" + "WORLD";
     strcpy(s, x.c_str());
  }
  </code></pre>
  
  <p>Above is cpp File.</p>
  
  <p>If I compile using <code>gcc</code> or <code>g++</code>, it doesn't compile and instead gives linker errors related to string.</p>
  
  <pre><code> compiler ex.c ex.cpp
  </code></pre>
  
  <p>What is a solution for string and multiset both?</p>