title: Performance C struct vs C++ struct/class
body: <p>I have a C struct with associated functions:</p>
  
  <pre><code>struct StructC {
      int a;
      int b;
  };
  
  static inline StructC func1()
  {
      StructC ret;
  
      //do something with variables ret.a and ret.b
  
      return ret;
  }
  
  static inline void func2(StructC var)
  {
     //do something with variables var.a and var.b
     ...
  }
  </code></pre>
  
  <p>and a C++ struct:</p>
  
  <pre><code>struct StructCPP {
      int a;
      int b;
  
      StructCPP func3()        //can also be static
      {
          StructCPP ret;
          //do something with instance variables ret.a and ret.b
  
          return ret;
      }
  
      void func4()         //can't use static here since it operates on the instance variables
      {
          //do something with instance variables a and b
          ...
      }
  };
  </code></pre>
  
  <p>My question: Which is faster when passing these structs to functions/methods?</p>
  
  <p>Since the C functions operating on StructC are static, only one instance reside in memory, but what happens with the C++ methods in its struct? </p>
  
  <p>Do its methods (func3() and func4()) occupy redundant memory for every instance, or does the C++ compiler optimize it to hold only one instance, so while passing the C++ struct, only the instance variables, a and b, are passed?</p>
  
  <p>which function call to these functions is faster (if there is any difference)?:</p>
  
  <pre><code>void functionA(StructC var);      //StructC as argument
  void functionB(StructCPP var);    //StructCPP as argument
  </code></pre>
  
  <p>(The program is a mixture of C and C++)</p>