Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 16th, 2007, 11:27 PM   #1
amitpansuria
Newbie
 
Join Date: Aug 2007
Posts: 13
Rep Power: 0 amitpansuria is on a distinguished road
what is the base type of enum

helo i have asked in exam what that what is the base type of
enum
options are given bewlo
(1) long int
(2) short int
(3) signed int
(4) unsigned int

can u tell me what is the exact answer from the above option
Regards,
Amit
amitpansuria is offline   Reply With Quote
Old Aug 17th, 2007, 12:07 AM   #2
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5 lectricpharaoh will become famous soon enough
I think the answer you're looking for is int. However, while an enum can be assigned to an int without loss of data or a cast, this doesn't mean it's the same thing.

[edit] I didn't say signed int, but since that is implicit unless you specify unsigned, I figured it was obvious. Thus, the teacher was probably looking for choice #3. [/edit]
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Aug 17th, 2007, 12:28 AM   #3
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
The teacher should be taken out and summarily shot for asking that question in that form. The correct answer is "(5) any integral type, including any of those above". And because the term "base type" has no meaning when discussing enumerations.

An enum is a distinct type with named constant integral values. The underlying type (a term used in the standard to represent an integral type that can represent all the values defined in an enumeration) is implementation defined (i.e. it depends on the compiler). Even more importantly, the underlying type can depend on the enumeration, depending on what values they hold -- so a particular compiler can support multiple underlying types, and select them appropriately for each enumerated type.

That said, if a teacher has asked that question, s/he probably thinks the answer is "(3) signed int". So you have the choice of giving the answer the teacher expects or the correct one. That choice needs to be based on consequences to the student (eg being marked down), not on correctness.
grumpy is offline   Reply With Quote
Old Aug 17th, 2007, 12:31 AM   #4
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4 Jessehk is on a distinguished road
Quote:
Originally Posted by grumpy View Post
So you have the choice of giving the answer the teacher expects or the correct one.
Don't you just hate when that happens? :p
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Old Aug 17th, 2007, 3:59 AM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5 lectricpharaoh will become famous soon enough
I've had a (very) few teachers who were willing to adjust their marking if you could make a case as to why your answer was correct. Such teachers seem to be in the minority, but if you're lucky enough to have one, I'd raise the point that the answer is none of the above, as grumpy points out. Otherwise, suck it up and answer '#3'.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I take a square root? Fall Back Son C 26 Oct 23rd, 2006 12:24 PM
Pointer return type,.. ??? Mack1982 C++ 28 May 26th, 2006 8:02 PM
C# corruption!!! Kilo C++ 32 May 21st, 2006 8:44 PM
Command Prompt SkyPioneer Coder's Corner Lounge 5 May 3rd, 2006 10:07 PM
base type has incomplete type Eric the Red C++ 4 Mar 3rd, 2006 8:04 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:07 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC