sizeof(array)显示错误的数字c ++

时间:2017-10-15 10:20:08

标签: c++ sizeof

我有一个

的课程
class IntFile
{
public:
    int value;
    int *array;
}

还有我的主要

int main()
{
    IntFile myfile;

    myfile.array = new int[CAPACITY];
    int number;
    cout << "Enter number of elements: " << endl;
    cin >> number;

    cout << "Enter your numbers: ";
    for ( int i = 0; i < number; i++)
    {
        cin >> myfile.value;
        myfile.array[i] = myfile.value;
    }
    cout << endl;

    int n = sizeof(myfile.array);

    cout << " THE SIZE OF ARRAY IS " << n << endl;



    delete[]myfile.array;

    cout << endl;
    return 0;
}

sizeof(array)= 4 *数组中的元素数量不应该吗? 因为对我来说,我总是得到sizeof(myfile.array)= 4

CAPACITY是全球性的,= 1000;

0 个答案:

没有答案