0

In my .hpp file I have two classes definitions:

class c1
{
    protected:
        int size;
        ....
    public:
        read_data() { }
}

class c2
{
    friend class c1;
    public:
        void method() { }
        ...
}

Then, in the .cpp file I declare the functions

void c1::read_data()
{
    ....
    file >> size;
    ....
}    

void c2::method()
{
    int array[size];
}

But when I try to define the size of the vector I get an error message that says that size needs to be a constant. The problem is that I get the value of size in an external file so I cannot declare as a constant.

Any ideas in what I can do to solve this? I consider also using structs if necessary.

MikeCAT
  • 73,922
  • 11
  • 45
  • 70
diego
  • 1
  • 1

0 Answers0