I have a class declaration in my header file like shown below. One function uses one of the struct as input and the other one as return parameter. The point is when I use in this way compiler gives me error.
What would be the reason ? Any idea is appreciated.
#include <string>
using namespace std;
namespace My_Functions
{
class My_Functions
{
public:
struct {
char input_a;
int input_b;
double input_c;
double input_d;
double input_e;
double input_f;
double input_g;
} Input_Parameters;
struct {
char output_a;
int output_b;
double output_c;
double output_d;
int output_e;
} Output_Parameters;
public:
Output_Parameters FindExit(Input_Parameters input);
};
}
in cpp file
My_Functions::Output_Parameters My_Functions::FindExit(My_Functions::Input_Parameters input)
{
}
There are three ways to fix your problem.
A.
struct struct_name {};
-> This declare structure called 'structure_name'B.
typedef struct {}struct_name;
-> usingtypedef
before your structure will be useful if you don't want to use 'struct
' keyword before name.C. Use
struct
keyword in function prototype.Ex for A: