Connecting Tech Pros Worldwide Forums | Help | Site Map

Unknown use of protected member functions.

tomas
Guest
 
Posts: n/a
#1: Jun 27 '08
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

Ian Collins
Guest
 
Posts: n/a
#2: Jun 27 '08

re: Unknown use of protected member functions.


tomas wrote:
Quote:
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.

--
Ian Collins.
sk_usenet
Guest
 
Posts: n/a
#3: Jun 27 '08

re: Unknown use of protected member functions.


"tomas" <tomasorti@gmail.comwrote in messageHi.
Quote:
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.
--
http://techytalk.googlepages.com


Closed Thread