C++ using a struct as a argument for a class
<p>I just cant work out how to get this working, theres another good question "Passing a struct as a constructor parameter in C++" which I though solved all my problems but I just dont get why my code is not working. I have three files namely: A source file </p>

<pre><code>// A.cpp

#include "myClass.h"

int main()
{
    struct myStruct {
        double a; 
        double b; 
    };

   myStruct structName;
   structName.a = 1.1;
   structName.b = 2.2;

   myClass myClassObject(60.0, structName);

   return 0;
}
</code></pre>

<p>A class header file</p>

<pre><code>// myClass.h

class myClass {
    private:
        double m_value; 
        double m_a; 
        double m_b; 

    public:
        myClass(double value, struct myStruct);
        ~myClass();
};
</code></pre>

<p>and another source file with the class definitions</p>

<pre><code>// myClass.cpp

#include "myClass.h"

myClass::myClass(double S, const myStruct &amp;s): m_value(S), m_a(s.a), m_b(s.b) {};
myClass::~myClass(){};
</code></pre>

<p>I get all sorts of errors, like in myClass source file I get Error: no instance of overloaded function "myClass::myClass" matches specified type.</p>

<p>Now if I remove</p>

<pre><code>struct myStruct
{
    double a; 
    double b; 
};
</code></pre>

<p>from the A cpp source file and put it in the myClass header file, all the errors go away.</p>

<p>Q) Should the struct declaration go into the myClass header file, and be the only place I define this struct? is this the right way to code this?</p>