0
private:
    int arrSize;
    int currentSize;
    int* arr;

ArrayClass::ArrayClass(int capacity)
    : arrSize{capacity},
      arr{new int[capacity]}
{
}

I came upon this code today, and it is completely new to me.

Is this the same as

ArrayClass::ArrayClass(int capacity){
    arrSize = capacity;
    arr = new int[capacity];
}

Is there an advantage between one or the other?

Also I did a little research and and saw that: arrSize{capacity} was just referring to the value of "capacity" arrSize(capacity) copies the value of "capacity"

Is there any other information I should know about?

UnseededAndroid
  • 527
  • 4
  • 8
  • 15

0 Answers0