samedi 8 janvier 2022

Is int arr[ ] valid C++?

I am trying to understand if writing int arr[]; is valid in C++. So take for example,

int a[]; //is this valid?
extern int b[];//is this valid?

int (*ptrB)[]; //is this valid?
struct Name
{
    int k[]; //is this valid?
};
void func()
{
    ptrB++; //is this valid?
}
int a[10];
int b[10];
void bar()
{
    ptrB = &b;//is this valid?
    ptrB++; //is this valid?
}
int main()
{
    int c[];//is this valid?
    extern int d[]; //is this valid?
}

int c[10];
int d[10];

I have read some comments on SO stating that int p[]; is not valid C++. So i wanted to know in what situations is this valid/invalid. For that i wrote the above snippet and want to understand through this example.

Aucun commentaire:

Enregistrer un commentaire