Hello, i have a problem with the C++. Below is the code. When compile, there is an error.
error C2466: cannot allocate an array of constant size 0
Can anybody answer me?
#include <iostream.h>
#include <string.h>
class samp{
int a;
public:
void set(int n){a=n;}
int get() {return a;}
};
int main()
{
int x;
cin>>x;
samp obj[x];
int i;
for(i=0;i<x;i++)
obj[i].set(i);
for(i=0;i<x;i++)
cout<<obj[i].get();
return 0;
}