Rotate Camera C++

According to your comment, I could have made an error in my approach to solve for camera rotation.
Could there be a correct way to rotate the camera?

Thanks.