DEV Community

Quoc Bao
Quoc Bao

Posted on

Introduction to OOP and array class implementation [part 2]

Last time, we left off with the default constructor. Remember that it has no arguments, which is why it is also called non-parameterized constructor. Therefore, this time we’ll kick off with parameterized constructor, which takes in user’s initial values.

Array::Array(int num_elements)
{
    allocate(this->A, num_elements);
    this->na = 0;
    this->capacity_a = num_elements;
}
Enter fullscreen mode Exit fullscreen mode

Read more here!

Latest comments (0)