Jump to content

  • Log In with Google      Sign In   
  • Create Account


Accessing enum from inherited class


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 ryt   Members   -  Reputation: 294

Like
0Likes
Like

Posted 24 January 2014 - 04:10 PM

In C# in my base class Weapon I have declared a enum Firestate like:

enum Firestate
{
    Fire
};
 
public class Weapon : MonoBehaviour
{
    public Firestate firestate;
};

And in a inherited class Gun I use that enum. But I get error CS0052: Inconsistent accessibility: field type 'Firestate' is less accessible than field 'Weapon.firestate'.
When I remove public from firestate there is no error but then I cant use it in Gun since it is private.


Edited by ryt, 24 January 2014 - 04:11 PM.


Sponsor:

#2 SeanMiddleditch   Members   -  Reputation: 3489

Like
1Likes
Like

Posted 24 January 2014 - 05:45 PM

The error is pretty descriptive. Your class Weapon has a public enum field, but the enum itself is not public. How could anyone actually use the firestate field if they can't access the values in the Firestate enum? Make the Firestate enum public.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS