为什么在C ++中不允许额外的方法限定? [英] Why in C++ extra method qualification is not allowed?

查看:193
本文介绍了为什么在C ++中不允许额外的方法限定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么原因我们不能用C ++编写

Is there a reason we can not write in C++

class MyClass
{
public:
    void MyClass::MyMethod();  // <----
}

这样的编译错误,但是有没有原因或者它只是这样发生了?

it gives 'extra qualification' or some such compile error but is there a reason for that or it's just so happened?

推荐答案

因为这是声明的语法;他们声明一个不合格名称在声明范围内具有特定的含义。

Because that's the syntax for declarations; they declare an unqualified name to have a particular meaning within the scope of the declaration.

如果允许范围限定, (指定当前范围)或错误(因为您不能在另一个范围中声明某个内容)。

If a scope qualification were allowed, it would always be either redundant (specifying the current scope) or wrong (since you can't declare something in another scope).

这篇关于为什么在C ++中不允许额外的方法限定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆