✨ ベストアンサー ✨
動名詞だと思ったのですが → 動名詞ではなく、完了形・現在分詞(=形容詞:前の名詞を後置修飾)と考えることは可能です。
しかし、完了形の時制(=過去完了←was(過去)より時間的に前の時制)は、この文の内容では矛盾があり、これも✕
John F. Kennedy was the first <[Catholic](名詞)+✕[having](完了形・動名詞)> been elected President of the United States.
※✕名詞+(動)名詞
John F. Kennedy was the first [Catholic](名詞) ✕<[having been elected](完了形・現在分詞) President of the United States. = John F. Kennedy was(過去) the first Catholic who ✕had been elected(過去完了) President of the United States.
※ジョン・F・ケネディーがアメリカ合衆国の大統領に選ばれたことが、彼が最初のカトリック教徒であったことより「時間的に前であった」ことは、事実の矛盾である。
参考にしてください。
You're welcome!😊
ご丁寧にありがとうございます