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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.