C++ basic question...enum and struct explanation.?
-
Im trying to finish up the last chapter of work for my first class in c++ programming. Im at home trying to read this chapter on enum user defined data types and struct data types. There is alot of noise in my home and its just not registering too well of what these data types do, why they exist, and when they would be useful. Can someone out there that is a fluent c++ programmer and understands these data types very well, explain to me these two data types in the most basic laymans terms. Im just backed up trying to finish the semester and my brain is overloaded right now. So someone please help. SOOOOO LAYMANS TERMS, ENUM: what is it and why is it useful, STRUCT: what is it and why is it useful, before my brain explodes...so help save a life. lol thank you very much. p.s. basic simple laymans terms as possible. I do understand basic c++ programming.
-
Answer:
Enums are basically a replacement for a linear list of macro defintitons. You basically set up a list of english words and they correspond to an integer number (in linear order). Structs are basically like a baby class. You can put as many types of variables inside a struct that you want, but (at least they way they were supposed to work) you can't define methods/functions in them. You use enums when you want to make parameter passing very easy for someone that is working on your project. In the curses library, they use enum definitions to pass colors (like COLOR_YELLOW) between functions. You use a struct when you need to define your own variable type that is full of primitive types. Structs are probably mainly used for data structures such as lists, trees, queues, and stacks.
Allen Hayes at Yahoo! Answers Visit the source
Related Q & A:
- What are some basic c++ programming techniques?Best solution by Quora
- How to learn C# (moving from C++ to C#?Best solution by stackoverflow.com
- How Can I Convert Struct?Best solution by Stack Overflow
- What is the scientific explanation for dreams?Best solution by Yahoo! Answers
- Is there any scientific explanation for Deja Vu?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.