c++, control reaches end of non-void function [-Wreturn-type]

  c++

I get an error(control reaches end of non-void function [-Wreturn-type]) when compiling this code:
It should return true if there are no gaps in the string and false if there are gaps.

bool isSafeBridge(string bridge){
    for (int i = 0; i < bridge.length(); i++)
    {
        if (bridge[i] == ' ')
        {
            return false;
        }
        else{
            return true;
        }
    }
}

int main(){
    cout<<isSafeBridge("####");
}

Source: Windows Questions C++

LEAVE A COMMENT