「C++」関数パラメータを使用する方法
書式
void functionName(parameter1, parameter2, parameter3) {
処理コード
}
使用例
#include <iostream>
#include <string>
using namespace std;
void testFunction(string fname) {
cout << fname << " data\n";
}
int main() {
testFunction("111");
testFunction("222");
testFunction("333");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
void testFunction(string fname) {
cout << fname << " data\n";
}
int main() {
testFunction("111");
testFunction("222");
testFunction("333");
return 0;
}
#include <iostream> #include <string> using namespace std; void testFunction(string fname) { cout << fname << " data\n"; } int main() { testFunction("111"); testFunction("222"); testFunction("333"); return 0; }
結果
111 data
222 data
333 data