Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
特にメモリ管理を扱う場合、C++ で goto を使用するのは悪い習慣だと聞きました。一方、再帰呼び出しを使用すると、関数の現在のインスタンスが停止し、新しいインスタンスが停止するまで待機することになります。これは、停止条件に達するまで非常に長い時間続く可能性があります。
再帰または goto を使用せずに関数を停止して再起動するか、ループの先頭に戻る方法はありますか?
次の例のように、単純に無限ループを使用できます。
function dontLikeGotos() { while(true) { //whatever } }
と同じです
function yummiGotos() { beginning: //whatever goto beginning; }
記録として、goto はいくつかの理由で Java では使用できません。