|
-
Oct 8th, 2005, 02:32 AM
#1
Thread Starter
Frenzied Member
Enumeration in Interface
Can one create a variable of which the type is an enumeration in an Interface class?
For instance:
I created an interface called IResource. The resource will either be a code file, image, document, etc.
So, I want to create an enumeration (ResourceTypes), and in the interface declare a property "ResourceType" whose value will be a member of the ResourceTypes enumeration, and will be set in derived classes.
I'm new to actually using interfaces, etc
Last edited by StrangerInBeijing; Oct 8th, 2005 at 09:17 PM.
Reason: Resolved
-
Oct 8th, 2005, 03:59 AM
#2
Re: Enumeration in Interface
You can do it, but I'm not aware of any enumerated types that are members of an interface. All the enumerated types I can think of are members of a namespace directly and not nested within a class or other type.
-
Oct 8th, 2005, 08:12 PM
#3
Thread Starter
Frenzied Member
Re: Enumeration in Interface
Oi, I did not know that!
I just created the enumeration BEFORE the class declaration, and it works.
Thought everything got to be inside a class. Little confused, but will look into it.
Some explanation would be welcome though.
-
Oct 8th, 2005, 09:13 PM
#4
Re: Enumeration in Interface
An enumeration is a type in itself, so you can define one anywhere you can define a class, or any other type for that matter. It can be nested within another type, like a class or interface, or it can be defined elsewhere in a code file. You might define it in the same file as a class, but outside the class definition, or you could define it in its own code file, along with other types or on its own.
-
Oct 8th, 2005, 09:16 PM
#5
Thread Starter
Frenzied Member
Re: Enumeration in Interface
Thanks matey!
Wonder how many other things is there I don't have a clue about.
-
Oct 10th, 2005, 06:04 AM
#6
Hyperactive Member
Re: Enumeration in Interface
 Originally Posted by StrangerInBeijing
I just created the enumeration BEFORE the class declaration
That means it is in the same namespace as the class who's declaration follows it's declaration.
There is actually no link between them, other than being declared in the same file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|