Unknown use of protected member functions.

T

tomas

Hi.
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?

Tom
 
I

Ian Collins

tomas said:
Hi.
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?
To make them public.
 
S

sk_usenet

tomas said:
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?

It means that init and run are now in the public interface of B. Without
them they would be inaccessible to the outside world (unrelated classes).

int main()
{
A a;
a.init(); // Inaccessible
B b;
b.init(); // Kosher
}

So B has basically modified what it exposes to the outside world.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top