如何将枚举变量作为返回值

1.首先需要定义枚举变量

typedef enum _Resolution
{
  _720P;
  _VGA;
  _QVGA;
}Resolution;
//声明一个枚举变量类型 _Resolution,并且将该枚举变量定义为 Resolution
2.新建枚举变量对象,并根据需求设置其取值
static Resolution resolution;//新建静态枚举变量

int _stdcall setResolution(Resolution _resolution)
{
  if (720P == _resolution)
  {
    resolution = _resolution;
    scale = 1.0f;
  }
  else if(VGA == _resolution)
  {
    resolution = _resolution;
    scale = 0.5;
  }
  else if(QVGA == _resolution)
  {
    resolution = _resolution;
    scale = 0.25;
  }
  else
  {
    return -1;
  }
  return 0;
} 

3.将枚举变量赋值作为函数返回值输出

Resolution _stdcall getResolution()
{
  return resolution;//setResolution中赋值
}



你可能感兴趣的:(OpenCV算法)