M
muler
Hi all,
Given (adapted from the C++ 98 standard document):
class A { };
class B : public A { };
namespace M {
namespace N {
class X : public B {
void f();
};
}
}
void M::N::X::f() {
i = 16;
}
Question: which scopes are searched for the declaration of i?
My answer:
1) outermost block scope of M::N::X::f, before the use of i
2) scope of class M::N::X
3) scope of M::N::X’s base class B
4) scope of M::N::X::B's base class A
5) scope of namespace M::N
6) scope of namespace M
7) global scope, before the definition of M::N::X::f
I'm not sure if i'm right about 4), can someone confirm?
Thanks,
Given (adapted from the C++ 98 standard document):
class A { };
class B : public A { };
namespace M {
namespace N {
class X : public B {
void f();
};
}
}
void M::N::X::f() {
i = 16;
}
Question: which scopes are searched for the declaration of i?
My answer:
1) outermost block scope of M::N::X::f, before the use of i
2) scope of class M::N::X
3) scope of M::N::X’s base class B
4) scope of M::N::X::B's base class A
5) scope of namespace M::N
6) scope of namespace M
7) global scope, before the definition of M::N::X::f
I'm not sure if i'm right about 4), can someone confirm?
Thanks,