473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Unknown use of protected member functions.

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
Jun 27 '08 #1
2 1157
tomas wrote:
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.
Jun 27 '08 #2
"tomas" <to*******@gmail.comwrote in messageHi.
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
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kevin Saff | last post by:
Apparently I'm missing something. Stroustrup (15.3) says of protected access: If is protected, its name can be used only by member functions and friends of the class in which it is declared...
6
by: Chris Mantoulidis | last post by:
Forgive me if I'm wrong but I think there is something like an extra member scope in classes. for example: class abc { ostream & operator << (ostream &, const abc &); istream & operator >>...
5
by: Daniel Aarno | last post by:
Can anyone provide a good explanation to why the following does not work? After all since A is a public base of B objects of type B ISA object of type A. class A { protected: void foo() {} };...
13
by: Adam H. Peterson | last post by:
I just made an observation and I wondered if it's generally known (or if I'm missing something). My observation is that static protected members are essentially useless, only a hint to the user. ...
3
by: Jordan Taylor | last post by:
I am confused about protected member functions and objects. Is there any particular advantage of declaring members protected?
7
by: atomik.fungus | last post by:
Hi, im having problems compiling some code, and i dont understand why. I've made a Matrix class for any kind of data and now im implementing an inherited class with all the mathematical stuff...
14
by: mlimber | last post by:
In an article on the safe bool idiom (http://www.artima.com/cppsource/safeboolP.html), Bjorn Karlsson gives the following code (slightly modified): class safe_bool_base { protected: typedef...
4
by: Joseph Paterson | last post by:
Hi all, I'm having some trouble with the following code (simplified to show the problem) class Counter { protected: int m_counter; }
3
by: Dmitry | last post by:
Hi all, Consider the following code: class A { public: A() {} void DoMethod() { (this->*m_pMethod)(); } protected: virtual void MethodA() { ... }
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.