Dear mates,
This is just a small survey for the common (and uncommon) nontrivial
uses of the aforementioned C++ construct.
It's posted by an average C++ programmer who's curious about how his
elder colleagues utilize this feature of C++ in their implementations
based on diverse programming styles in diverse application domains.
Thank you for your interest.
Best regards,
//rk 5 16919
"Razmig K" <st*********@postmaster.co.uk> wrote in message
news:3c**************************@posting.google.c om... Dear mates,
This is just a small survey for the common (and uncommon) nontrivial uses of the aforementioned C++ construct. It's posted by an average C++ programmer who's curious about how his elder colleagues utilize this feature of C++ in their implementations based on diverse programming styles in diverse application domains.
Though I am far from being an 'elder' colleague, here goes.
I can only think of occasions, where I used enums to give constants a
name, as well as to group them (the constants). Suppose I was writing a
text-processor which enables you to align the text. All possible options to
align that text would go into one enum. Another (slightly different) usage
would be putting all options for formatting the font (bold, italics,
underline etc) in another enum. Now you do not only pass a single value, but
I may also combine them.
Recently, I also used enums as named indeces into an array. This does
not really fit into the group-and-give-name category and I do not think it
is used often. Personally, I have used it only once so far.
regards
--
jb
(replace y with x if you want to reply by e-mail)
Noah Roberts <nr******@dontemailme.com> wrote in message news:<3F**************@dontemailme.com>... Razmig K wrote: Dear mates,
This is just a small survey for the common (and uncommon) nontrivial uses of the aforementioned C++ construct. It's posted by an average C++ programmer who's curious about how his elder colleagues utilize this feature of C++ in their implementations based on diverse programming styles in diverse application domains.
Thank you for your interest.
Best regards, //rk
I used to use enums to declair methods only capable of accepting or returning certaing integer values. It really become more pain than it is worth most of the time in many of the applications I put it to; plus I am not too sure it actually works that way :P
Mainly now I just use enums to declair sets of constants that I want to be distinct, many of which are used as induces to arrays. For instance I use two enums in the interface to my Board class in a chess engine I am working on:
enum { red, black } enum { empty, all = 0, pawn, canon, cart, horse, elephant, guard, general };
pawns = boardInstance[red][pawn]; // returns the red pawn board.
and so on...
Things like that make my code more pleasant, and it needs things like that :P
I also use it to refer to things that don't necissarily have to be in any order, or even next to each other, but must be distinct and/or are related in idea. For instance, my interface modes are specified in an enum; not because they care what the numbers are, but because they are related and it groups symbols for readability...and there is a lot less typing than with a bunch of #defines.
NR
PS. No, I am not an "elder" programmer. Especially with C++ as I have been more of a C or Objective-C man in the past. And yes, that is a pretty trivial use :P
Do you realize that in your example above (using GCC 3.2.2 on Solaris)
the value of empty ends up being 0? Did you expect it to equal -1? enum { red, black } enum { empty, all = 0, pawn, canon, cart, horse, elephant, guard, general };
Do you realize that in your example above (using GCC 3.2.2 on Solaris) the value of empty ends up being 0? Did you expect it to equal -1?
No, I expected it to be 0 as it should be in any and all C/C++ compilers
afaik.
NR
>Razmig K wrote: Dear mates,
This is just a small survey for the common (and uncommon) nontrivial uses of the aforementioned C++ construct. It's posted by an average C++ programmer who's curious about how his elder colleagues utilize this feature of C++ in their implementations based on diverse programming styles in diverse application domains.
Thank you for your interest.
Best regards, //rk
I use ENUMS to give names to integer constants, to give a type to a set of
related constants, and to give names to bit fields within integers (e.g. in a
hardware device register).
For example:
enum REG1_bits_T {
REG1_ENABLE_FROBNITZ = 0x04000000,
REG1_ENABLE_BOOMBAH = 0x02000000,
REG1_BLATHER_MASK = 0x00f00000,
REG1_BLATHER_SHIFT = 20
};
Then I use the bits like so...
reg1 = reg1 | REG1_ENABLE_FROBNITZ; // Enable Frobnitz
reg1 = reg1 & ~REG1_ENABLE_BOOMBAH; // Disable Boombah
reg1 = reg1 & ~REG1_BLATHER_MASK;
reg1 = reg1 | ((blather_value) << REG1_BLATHER_SHIFT); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Damian Brown |
last post by:
www.phpexpert.org
|
by: Lucas Raab |
last post by:
One thing I've always kind of wondered is what is the average age of a
Python programmer?? What age groups use Python?? Something to think
about....
|
by: Zooko O'Whielacronx |
last post by:
I'm a fan of Greg Ewing's PyGUI . I used it to code a simple game
for my son , and enjoyed it. Programming with wxPython feels like
programming with a C++ tool that has been wrapped in Python....
|
by: James Cameron |
last post by:
Hi I'm developing a program and the client is worried about future
reuse of the code. Say 5, 10, 15 years down the road. This will be a
major factor in selecting the development language. Any...
|
by: basecamp |
last post by:
just checking the average age of programmers using this group
--
thanks
|
by: amanda992004 |
last post by:
Excluding the factors of the brain capability, i.e I am not asking
about this factor, if you are a single, aside from enjoying coding or
debugging, how do you make time to eat properly, i.e...
|
by: guy |
last post by:
Stirring up trouble here;)
why is it that C# programmers try and denigrate VB.NET while VB.NET developers seem to have no problem with C# but just prefer VB.NET?
I use both and this generally seems...
|
by: M_Mann |
last post by:
Hello,
Pls excuse if you consider this off-topic. Conceptual artists seek
programmers here.
We are authors of "Exhibition of Living Managers" (MANAGEX,
www.managex.info) which is is global...
|
by: Biel |
last post by:
Folks,
One curiosity;
- When can I affirm that one programmer C++ have the advanced
level?
- Is there some classical definition of parameters applied to
C++ for define it?
|
by: geevaa |
last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3
XMLHttpRequest and AJAX for PHP programmers
James Kassemi
Introduction:
Although the concept isn't entirely new, XMLHttpRequest...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |