0
class MyClass
{
    int **a;
    int *b[];

    MyClass()
    {
        a = new int*[10];
        b = new int*[10];
    }
};

In the above code I get a compilation error at the 2nd line inside the constructor (b = new int*[10]). It says error: incompatible types in assignment of int**' toint*[0u]'

Why is it so?

bibbsey
  • 969
  • 2
  • 9
  • 14

1 Answers1

2

You can't assign to an array; you can initialize it or assign to its members. Your b member is invalid anyway since it is illegal to have an array of size 0; the syntax T b[] can only be used where an aggregate initializer is immediately provided allowing the compiler to infer the length of the array.

ecatmur
  • 152,476
  • 27
  • 293
  • 366