Explicitly Defining a Destructor - C++ Class

C++ examples for Class:Destructor

Description

Explicitly Defining a Destructor

#include <cinttypes>

class Car
{
private:
        int m_NumberOfWheels{};

public:
        Car() = default;

        Car(int numberOfWheels)
                : m_NumberOfWheels{ numberOfWheels }
        {

        }

        ~Car() = default;

        int GetNumberOfWheels()
        {
                return m_NumberOfWheels;
        }
};

Related Tutorials