Hey everybody!
First of all, I'm new here, just started learning C++ from the book written by Jesse Liberty et al.
While going through the chapters, I've stumbled upon a problem while trying to compile a listing from the book. I am using the g++ compiler in Linux, maybe it's a problem with the compiler itself, but until now, all the listings compiled perfectly.
It's about chapter 4 (if anyone has this book) and the listing is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
using namespace std;
int main()
{
int SomeArray[2][5]={{0,1,2,3,4},{0,2,4,6,8}};
for (int i=0; i<2; i++)
{
for (int j=0; j<5; j++)
{
cout << "SomeArray[" << i << "][" << j << "]: ";
cout << SomeArray[i][j] << endl;
}
}
return 0;
}
|
the compiler gives me these messages:
g++ l4li4.cpp -o l4li4
l4li4.cpp: In function ‘int main()’:
l4li4.cpp:9:8: error: expected primary-expression before ‘int’
l4li4.cpp:9:17: error: ‘j’ was not declared in this scope
l4li4.cpp:9:25: error: expected ‘;’ before ‘)’ token
I have checked and rechecked the code I've written with the example listing from the book and I can't find any typo's, help anyone?