本文介绍了分号在命名空间。必要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用命名空间时,我需要用分号来完成它吗?例如,当我将类的向前声明放入命名空间时,许多人不会包含分号,但似乎是可选的。

when working with namespace, I need to finish it with a semicolon? When I put a forward declaration of a class into a namespace, for example, many people doesn't include a semicolon but, it seems to be optional.

分号add功能或通过添加或删除?更改当前功能。

Does semicolon add functionality or change the current functionality by adding or removing?

谢谢。

推荐答案

如果分号是可选的,它不会改变功能,否则它会忽略它会导致语法错误。 / p>

If semicolon is optional it doesn't change functionality, otherwise it you omit it you'll get a syntax error.

namespace A {
    class B; // forward declaration, semicolon is mandatory.

    class B {
    }; // class definition, semicolon is mandatory

    class C {
    } f(); // because otherwise it is a return type of a function.
} // no need for semicolon

namespace D = A; // semicolon is mandatory.

如果这些不是您谈到的情况,请发表评论。

If these are not the cases you talked about, comment please.

这篇关于分号在命名空间。必要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 04:48