|
Post by nadhbv on Aug 10, 2005 23:23:53 GMT 5.5
I've written a code in c++ which is as follows:
#include <iostream> #include <fstream> using namespace std; class image { public: int x , int y; image() { ifstream fp1("imagevalue.txt"); // imagevalue.txt has two int values fp1 >> x >> y; } } imagexy;
const int i = imagexy.x, j = imagexy.y; int arr[j]; int main() { cout << i << "\t" << j; }
/* end of the program */
It gives an error stating that "variable size declared outside of any function" as the error message... which means that the int arr[j] should be defined inside some function and cannot be global. and if it has been defined inside the main or any other function, there shows no error message.
so anybody plz help me out with this problem and suggest a method of how to make the array arr[j] as globally accessible.
thank u
|
|
|
Post by y3knik on Aug 16, 2005 11:53:00 GMT 5.5
i dunno.. but try using &i, &j instead of i nd j inside da function.. mayb tht will work.. not sure though
|
|