A 40-pound dog is indeed too large to travel in-cabin on most (if not all) airlines and will have to ride as cargo.
Apart from very small pets, only trained and certified service or support dogs with legitimate documentation are sometimes allowed to accompany their owners in-cabin.