Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialazumi yuan
3,126 Pointssorry i really don't get this video can someone please teach me what's struct about?
can someone please explain to me what struct is about? its so confusing.
1 Answer
Jordan Aldujaili
5,852 PointsOk, so this is how I understand what a struct is, if I am wrong, I hope someone corrects me.
Here is a metaphor: Think of a way to define a fruit. It is sweet and there are seeds. Now you have two attributes to define the fruit instead of the just normal way of just being a string or an int.
typedef struct{
string seeds;
string sweetness;
} Fruit;
And now, instead of it being string *banana, its Fruit banana, which now you have access to the seeds and sweetness. Hope that makes sense