开发者

Why VS2010 wizard add void type in ctor and dtor?

Any time I add cl开发者_如何学编程ass via VS Wizard, I have these implementations:

class CDxWindow
{
public:
    CDxWindow(void);
    ~CDxWindow(void);
};

Usually I delete voids.

But maybe is there any reason of leaving them in the code?

Why does Microsoft added void there?


In C a function declared with no parameters is assumed to take a single integer parameter. Declaring the function with a void parameter list tells the compiler not to assume this default.

This doesn't apply in C++, so the void is unnecessary.


No reason, just someone being pedantic. You can safely delete void here if you want to.


I cannot tell you WHY they decided to do this, but all I know is that in C this is a construct to say there is no args to the function, so maybe that's what they are trying to say.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜