I wrote a code that would create a user-defined structure named Flight with flightNumber and flightMiles members
Will someone please correct me if I am wrongCode:struct Flight
{
int flightNumber;
int flightMiles;
};
Thanks
Jamina
Printable View
I wrote a code that would create a user-defined structure named Flight with flightNumber and flightMiles members
Will someone please correct me if I am wrongCode:struct Flight
{
int flightNumber;
int flightMiles;
};
Thanks
Jamina
The code looks right. But, do you have a problem with it? Otherwise the best way to test it is making your own program that uses it.
Yes, the code you posted defines (not creates) a struct named Flight with those members. Do note that this does NOT create any of these structures, it only tells the compiler how that structure is made. Until you create an instance of the structure, you can't do anything useful.
Yeah, remember to create an instance of the struct by doing:
but of course use a better name for yours :)Code:Flight instance_of_flight;
instance_of_flight.flightNumber=635;
instance_of_flight.flightMiles=22;