I'm reading my C++ book and I've come to a chapter on structures and unions. The book has tried to explain the difference but I'm not getting it's explanation. Playing with the structure examples in the book reminds me of accessing attributes to a python Class but apart from that, probobly inacurate observation, I don't really get them.
lewashby 56 Junior Poster
Recommended Answers
Jump to Postif the structure were a class
In C++, a struct IS a class. A class IS a struct. The only difference is the default member visibility (and related default inheritance). Everything you know about a class in C++ you also know about struct, because they're the same thing.
Jump to PostYou can make out the different of structure and union by going through the following points.
Structure :
1.The keyword struct is used to define a structure
2. When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater …
All 7 Replies
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
lewashby 56 Junior Poster
Moschops 683 Practically a Master Poster Featured Poster
sepp2k 378 Practically a Master Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
dinad578 9 Newbie Poster
cheryllocascio 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.