아주 간단한 프로그램입니다. 나는 함수를 위에서 정의하고 루프에서 함수를 호출하고있다 print
.왜이 루프가 작동하지 않습니까?
하지만 다음과 같은 오류가 점점 오전 :
prog.cpp:5: error: variable or field ‘print’ declared void
prog.cpp:5: error: ‘a’ was not declared in this scope
prog.cpp: In function ‘int main()’:
prog.cpp:11: error: ‘print’ was not declared in this scope
를 여기있다 :
#include <iostream>
using namespace std;
void print(a) {
cout << a << endl;
}
int main() {
for (int i = 1; i <= 50; i++) {
if (i % 2 == 0) print(i);
}
return 0;
}
"A"의 함수 매개 변수의 유형? – phantasmagoria
[이 좋은 C++ 자습서 세트] (http://www.cplusplus.com/doc/tutorial/)가 도움이 될 수 있습니다. – Gigi
왜 그렇게 많은 downvotes? OP는 최소한의 작업 예제를 제공하며 오류 메시지가 완료되었습니다. –