1

I have a class with

class IntFile
{
public:
    int value;
    int *array;
}

And there is my main

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;
}

Shouldn't the sizeof(array) = 4*number of elements in array? Because for me, I'm always getting sizeof(myfile.array) = 4

CAPACITY is global and = 1000;

AlexMIEL
  • 43
  • 3
  • 7

0 Answers0