私はC ++の初心者です。私の最初のアプリはそのように見えます。
#include "stdafx.h"
#include <iostream>
using namespace std;
int add (int x, int y);
int add (int x, int y){
return (x+y);
}
int _tmain(int argc, _TCHAR* argv[])
{
int x, y;
cin >>x>>y;
cout <<add (x,y);
cin.get();
return 0;
}
2 つの質問があります。
- を使用した場合でも、関数が値を返した直後にコンソールウィンドウが閉じるのはなぜ
cin.get();
ですか? int add (int x, int y);
ファイルの先頭に行を追加せずに、このアプリケーションをテストしました。うまくいきました。関数やアプリケーションがなくても動作するすべての関数またはアプリケーションのプロトタイプを作成する必要がありますか?