What is the meaning of having void in the constructor definition?

后端 未结 4 646
我寻月下人不归
我寻月下人不归 2021-02-13 02:28

Given the following code:

#pragma once

class B
{
public:

    B(void)
    {
    }

    ~B(void)
    {
    }
};

I know I can also write this:

4条回答
  •  日久生厌
    2021-02-13 02:47

    The two are same, at least in C++. In C, providing an empty pair of parentheses typically means an unspecified parameter list (as opposed to an empty parameter list). C++ does not have this problem.

    How can a correct answer get downvoted so many times? Yet another SO bug?

提交回复
热议问题