Hi,
if we define a vector class,
class vector
{
private:
int size;
int* array;
...........
public:
vector (int n=10);
.........
}
then we use it in main like this:
int main()
{
const vector v(5);
cout <<v(1) <<endl;
return 0;
}
there's a problem with compiling this code, i think because v is not initiliased and declared as const, and because the program is trying to output something both uninitialised and const, but how can i solve this problem, because the default constructor, as far as i know in this case, allocates an array of size 10 but without initialising, so how am i supposed to change class vector in order to make it compile?