#include <iostream>
#include <array>
using namespace std;
typedef int type;
typedef array <type,6> Liste;
bool appartient(type element, Liste liste);
int main()
{
Liste maliste = {4,5,-3,12,7,-33};
cout << appartient(13, maliste) << endl;
cout << appartient(12, maliste) << endl;
return 0;
}
bool appartient(type x, Liste liste)
{
for (auto element: liste) { //////this line!!!!!!!
if (x == element) return true;
}
return false;
}
I am working on this exercise of table in c++. Here I am writing a fonction "appartient" that verify the appartenance of an element on a list. But I have some errors in this fonction:
1/ error: expected initializer before ':' token
2/ error: expected primary-expression before 'return'
3/ error: expected ';' before 'return'
4/ error: expected primary-expression before 'return'
5/ error: expected ')' before 'return'
Why?
GCC 7.1.0
has no error – Shakiba Moshiri