I came across this question:
"There are two types of variable data – dependent and independent. Which type is recommended to be created inside a struct and why?"
My attempt at an answer:
So I created some structs
struct Node{
int node;
Node *ptr;
}
struct Book{
int page;
Book *nxtPg;
}
struct Fruit{
string name;
float weight;
}
I can see that the variables are dependent. Is it correct to say that dependent variables would be recommended because structs group similar data together. And to answer the why part, is it correct to say that independent variables would defeat the purpose of creating a struct?