Possible Duplicate:
c++ compiling “error: expected constructor, destructor, or type conversion before ‘=’ token ”
Here’s my C++ program. When I compile it, an error comes:
Line 6: Expected constructor, destructor or type conversion before '=' token.
Now I can’t see what’s wrong in it code-wise (i.e. logically it may be) and I can’t debug this error. Can somebody please tell me a remedy to this error?
#include<iostream>
using namespace std;
int go[10000],f[10000],n,i;
f[0]=1;
f[1]=1;
go[0]=1;
go[1]=1;
int g(int x) {
return (f[x-1] + go[x-1]);
}
int main() {
cin>>n;
for (i=2;i<=n;i++) {
f[i]=f[i-1]+f[i-2]+(2*g(i-2));
}
cout<<f[i];
system("PAUSE");
}
You should only assign values to variables inside function declarations.