Advertisement

10.22.2007 at 01:13PM PDT, ID: 22910111
[x]
Attachment Details

C++ enum types

Asked by cuziyq in C++ Programming Language

Tags: enum

I know what it's for, but I never really use enum for anything, so here's my question:

I am working on banking software.  I have a base class that has an account core type member.  It's an int that represents any of the various types of products the bank can offer.  If an object is being spawned from a derived class, can I use enum to constrain the core account type to only those values that correspond to relevant core types for the class being derived?  For example, if I write a loan module, the core account type should only be a mortgage, business loan, credit card, etc.  I want the compiler to throw an error (or possibly be caught in a try/catch block) if the core account type is set to something that doesn't apply to a loan (i.e. a savings or checking account).

Can enum do this?  How would I make a function that accepts only one of the enumerated types (even though the member is just an int)?Start Free Trial
[+][-]10.22.2007 at 01:44PM PDT, ID: 20126713

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.22.2007 at 02:09PM PDT, ID: 20126941

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.22.2007 at 11:36PM PDT, ID: 20128976

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.22.2007 at 11:39PM PDT, ID: 20128982

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.22.2007 at 11:42PM PDT, ID: 20128988

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.23.2007 at 12:02AM PDT, ID: 20129055

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.23.2007 at 12:07AM PDT, ID: 20129066

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.24.2007 at 03:21PM PDT, ID: 20143379

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C++ Programming Language
Tags: enum
Sign Up Now!
Solution Provided By: evilrix
Participating Experts: 4
Solution Grade: A
 
 
[+][-]11.13.2007 at 04:09PM PST, ID: 20276659

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906