转载于https://blog.csdn.net/qtyl1988/article/details/6882845
error: control may reach end of non-void function [-Werror,-Wreturn-type]
控制到达非void函数的结尾。就是说你的一些本应带有返回值的函数到达结尾后可能并没有返回任何值。这时候,最好检查一下是否每个控制流都会有返回值。
原错误代码:
#include<iostream>
using namespace std;
bool chkRotation(string A, int lena, string B, int lenb) {
if(lena != lenb)
return false;
string C = A+A;
if(C.find(B)!=string::npos)//错误
return true;
}
int main(){
bool a=chkRotation("1234",14,"2341",14);
cout<<a<<endl;
return 0;
}
应该是
if(C.find(B)!=string::npos)
return true;
else
return false;