English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a struct

struct MyStruct
{ string Airline_Node; // Name of up to 20 letters
int Flight_Node;
string City1_Node;
string City2_Node;
int Cost_Node;
int Passangers_Node;
};

In my main I made a dynamic array of structs and now I want to compare the variables

I tried

bool Compare_Flights( struct *Mystruct1, struct *MyStruct2){

//compare code

return true; //true or false depending on compare code
}

but I keep getting

error C2332: 'struct' : missing tag name

any help would be greatly apreciated :)

2007-04-27 18:58:38 · 2 answers · asked by dragongml 3 in Computers & Internet Programming & Design

By the way im using C++

2007-04-27 18:59:14 · update #1

2 answers

you need to give your struct a name.

change
struct MyStruct
{ string Airline_Node; // Name of up to 20 letters
int Flight_Node;
string City1_Node;
string City2_Node;
int Cost_Node;
int Passangers_Node;
};


to
struct MyStruct
{ string Airline_Node; // Name of up to 20 letters
int Flight_Node;
string City1_Node;
string City2_Node;
int Cost_Node;
int Passangers_Node;
} Node; //or whatever you want to name it

then declare your 2 structs like this
Node Mystruct1, Mystruct2;//or whatever you want to name them

then to pass them
bool Compare_Flights(&Mystruct1, &Mystruct2);

your compare function
bool Compare_Flights(struct &Mystruct1,struct &Mystruct2)
{
//your code
}


off the top of my head, i think this is right

2007-04-28 01:14:10 · answer #1 · answered by justme 7 · 0 0

Try:

struct { } MyStruct;

And why isn't MyStruct a class? Since you are using C++, you ought to be. Then you can overload the equal operator and implement the compare that way.

2007-04-28 02:57:08 · answer #2 · answered by ZeroCarbonImpact 3 · 0 1

fedest.com, questions and answers