'Why in Array sizeof(A[0]) and sizeof(A+0) are different?

I have started learning pointer in C++ and I solved a lot of problems with it but I can't solve this problem? Can anyone explain me this problem?

Here is my test code:

#include <iostream>
using namespace std;

int main(){
    int A[]= {1,2,3,4,5};
     cout<<"Size of A in main = "<<sizeof(A)<<endl;
     cout<<"Size of A[0] in main = "<<sizeof(A[0])<<endl;
     cout<<"Size of A+0 in main = "<<sizeof(A+0)<<endl;
     return 0;
}

Here is my problem - I get this output:

Size of A in main = 20
Size of A[0] in main = 4
Size of A+0 in main = 8
c++


Solution 1:[1]

A[0] means element at a+0 . i.e., *(A+0) which is int in your case and the size of int is 4 bytes. A+0 means pointer and its size is 8 bytes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 balu