我在功能方面遇到了一个小问题。我相信这可能是因为我没有正确使用它们。我的代码如下:
int duration(string fraction)
{
// X part of the fraction
int numerator = fraction[0];
// Y part of the fraction
int denominator = fraction[2];
// Checking for eighth note, quarter note and half note
if (numerator == 1)
{
switch (denominator)
{
case 8:
return 1;
case 4:
return 2;
case 2:
return 4;
}
}
// Checking for dotted quarter note
else
return 3;
}
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题导致我收到此特定错误:
错误:控制可能到达非 void 函数的末尾 [-Werror,-Wreturn-type]
c ×1