I'm working with a C++ framework that has something like this:
class A {
protected:
virtual void init();
virtual void run();
// rest of the class
...
}
class B : public A {
public:
A::init;
A::run;
// rest of the class
...
}
I have never seem the use of A::init; and A::run; in that way before.
What are they supposed to be?
How do they afect to class B?
What do you think is the purpose of them?
ropez wrote:
> I'm not sure about this, I think you're supposed to include the
> using keyword like this:
1 2
using A::init;
using A::run;
>
> ..or it may have a slightly different meaning.
I have always seen it like that too. I wonder if someone else can comment on this that is a bit more knowledgeable. The only thing I can think of is the idea that the code was created before C++ had a 'using' keyword...
Section 11.3 Access declarations, paragraph 1 of ISO/IEC 14882:1998 states:
The access of a member of a base class can be changed in the derived class by mentioning its qualified-id in the derived class declaration. Such mention is called an access declaration. The effect of an access declaration ‘qualified-id;’ is defined to be equivalent to the declaration ‘using qualified-id;’. *
*Access declarations are deprecated; member using-declarations (7.3.3) provide a better means of doing the same thing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
class A {
protected:
virtualvoid init(){};
virtualvoid run(){};
};
class B : public A {
public:
A::init; //Access declarations (98std 11.3)
A::run; //Access declarations (98std 11.3)
};
class C : public A
{
public:
using A::init; //Using-declaration used as member-declaration (98std 7.3.3.4)
using A::run; //Using-declaration used as member-declaration (98sts 7.3.3.4)
};