8

I`ve problem compiling my program because of this strange compile error...here is the concrete part of code:

 // the error occures at "char _adr[][]" in the constructor parameters

Addresses(string _ime, string _egn, char *_adres, char _adr[][], int adrLen):Person(_ime, _egn, _adres){
    addressLength = 0;
    for(; addressLength < adrLen; addressLength++) {
        if(addressLength >= 5){
            break;
        }
        adr[addressLength] = _adr[addressLength];
    }
}
3
  • Where is adr defined at?
    – JaredPar
    Jan 12, 2014 at 19:15
  • 1
    You should specify last column size in definition: char _adr[][256] Jan 12, 2014 at 19:19
  • multidimensional array must have bounds for all dimensions except the first Jan 12, 2014 at 19:22

1 Answer 1

17

In C/C++ you cannot define a bi-dimensional array with two unknown size as in char _adr[][]. Arrays declarations must have all, but the first, sizes defined. Try defining at least one size (example: char _adr[][10]) or, since you are using C++, use an std::vector instead.

Just to make you notice it: you are also using the adr without declaring it in the scope of the function.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.