C++ Constructor with variable initialization

C++ Constructor with variable initialization

I am reading a book about data structures and I stumbled upon this block of code:

I am reading a book about data structures and I stumbled upon this block of code:

class UnorderedArray 
{
public:
UnorderedArray(int size, int growBy = 1) :
    m_array(NULL), m_maxSize(0), m_growSize(0), m_numElements(0)
{
    if (size) {
        m_maxSize = size;
        m_array = new T[m_maxSize];

    m_growSize = ((growBy > 0) ? growBy : 0);
}

}

private: T * m_array;

int m_maxSize; int m_growSize; int m_numElements;

}

Can someone explain this block of code for me?

UnorderedArray(int size, int growBy = 1) :
m_array(NULL), m_maxSize(0), m_growSize(0), m_numElements(0)

I believe this is some sort of initialization for those variables but I can't seem to find a concrete answer.

c++

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look

C++ Tutorial for Beginners 19 - C++ Structures | Struct declaration | C++ Data Structures

Welcome to this course on C++ Tutorial for Beginners. In this video we will see How to use C++ Structures.

Object Oriented Programming in C++ | C++ OOPs Concepts | Learn Object Oriented C++

C++ is general purpose, compiled, object-oriented programming language and its concepts served as the basis for several other languages such as Java, Python, Ruby, Perl etc.

A Complete Guide to fread() in C/C++

In this article, we’ll take a look at using fread() in C/C++.