title: Declaring struct in header C++
body: <p>I'm trying to use a struct to output two values from a function to then be used in the main. I am using a header file to call the functions to be used. The code is compiling but the values I'm getting are not correct. I don't know if I'm declaring the struct correct in my .h file or where something is getting used incorrectly. At the moment, my .h file looks like: </p>
  
  <pre><code>#ifndef LINEAR_DISPERSION_SOLVER_H
  #define LINEAR_DISPERSION_SOLVER_H
  
  //Function for dispersion relation equation
  double f (double L, double T, double g, double d);
  
  //Function for derivative of linear dispersion relation 
  double df(double L, double T, double g, double d);
  
  //Wave parameter struct definition 
  
  struct wave_parameters {
    double kn;
    double w; 
  };
  
  //Linear Dispersion Solver function 
  wave_parameters linear_dispersion();
  
  #endif
  </code></pre>
  
  <p>And a portion of my .cpp (not main) looks like: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cmath&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  struct wave_parameters {
    double kn;
    double w; 
  };
  float pi = 3.1415927;
  
  double f(double L, double T, double g, double d) {
    return (g*g);
  }
  
  double df(double L, double T, double g, double d) {
    return (1 + ((g*T*T*d)/(L*L)) 
  }
  
  
  struct wave_parameters linear_dispersion () {
  
  .... Deleted code .....
  
      int choice; 
  
  
      cout &lt;&lt; "Enter the depth of water ---&gt; ";
      cin &gt;&gt; d;
  
      cout &lt;&lt; "Enter 1 to solve for wave number or 2 to solve for frequency --&gt; ";
      cin &gt;&gt; choice;
  
      //Calling the wave struct to fill with values 
  
      struct wave_parameters wave; 
  
      if (choice == 1) {
        cout &lt;&lt; "Enter the value for period ---&gt; ";
        cin &gt;&gt; T; 
  
  .... Deleted code ....
  
        wave.kn = k; 
        wave.w = omega; 
  
  return wave; 
  }
  </code></pre>
  
  <p>My main then includes the .h file and calls the .cpp file using:</p>
  
  <pre><code> struct wave_parameters wave;
   kn = wave.kn;
  </code></pre>
  
  <p>Is this the correct method to outputting multiple variables and then using a header file? As you can see, I've declared my struct twice (once in my .h and once in my .cpp file) but I was doing this as i was getting errors otherwise. Any help is really appreciated! </p>