1
在以下代碼片段中,爲什麼內部類CheckForA
方法中的'A'不必是合格標識(即return myE == Outer::A
)?是因爲E和Inner都在同一個範圍內嗎?類範圍是否像命名空間範圍一樣工作?內部類訪問外部類嵌套枚舉
class Outer
{
public:
enum E{ A, B, C };
class Inner
{
public:
void Set(E e_) { myE = e_; }
bool CheckForA() const { return myE == A; }
E myE;
};
void Set(E e_) { myInner.Set(e_); }
bool CheckForA() const { return myInner.CheckForA(); };
Inner myInner;
};
int main()
{
Outer outer;
outer.Set(Outer::A);
return (int)outer.CheckForA();
}
所以,大概是枚舉...... – Elpoca 2014-09-05 19:35:06