check whether certain variable is member of that structure
Feb 12, 2018 at 7:43am UTC
I want to check if certain variable is member of structure or not.
For example, I have a structure like this:
1 2 3 4 5 6
struct distance
{
int feet;
int inches;
char name;
};
How to check if "feet" is member of structure or not?
Last edited on Feb 12, 2018 at 7:45am UTC
Feb 12, 2018 at 8:17am UTC
Please explain more. Show an example, where you have mysterious feet.
Feb 12, 2018 at 8:20am UTC
For a generic implementation.. I don't know in which structure that variable is initialized. So have to check to each structure in which structure that particular variable is declared...if not check in other structure.
Feb 12, 2018 at 9:02am UTC
A struct is a class. Members of a class should be initialized by the constructor of the class. Initialization is nobody else's business.
Topic archived. No new replies allowed.