Это очень простая программа. У меня есть функция, определенная сверху и в цикле. Я вызываю функцию 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;
}
Тип "а" в параметре функции? – phantasmagoria
[Этот хороший набор учебников C++] (http://www.cplusplus.com/doc/tutorial/) может вам помочь. – Gigi
почему так много downvotes? OP обеспечивает минимальный рабочий пример и сообщение об ошибке завершено. –