Returning an enum from a function in C?

后端 未结 4 1687
醉酒成梦
醉酒成梦 2020-12-14 00:51

If I have something like the following in a header file, how do I declare a function that returns an enum of type Foo?

enum Foo
{
   BAR,
   BAZ
};
         


        
4条回答
  •  無奈伤痛
    2020-12-14 01:36

    I believe that the individual values in the enum are identifiers in their own right, just use:

    enum Foo testFunc(){
      return BAR;
    }
    

提交回复
热议问题