472,353 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Can Derived class static member access protected member from base class?

Can Derived class static member access protected member from base class?

class Base {
protected:
void setvariable(int);
};

class Derived : Base {
public:
static std::auto_ptr<Base> out(new Derived());
out->setvariable(3); // my compiler gives is not accessible error here!
return out;
};
Jul 22 '05 #1
4 2902
Siemel Naran wrote:
Can Derived class static member access protected member from base class?


No. Same reasons why it doesn't for a non-static member.
(I'm assuming that all that stuff after public: in Derived
is really in a member function).
Jul 22 '05 #2
Ron Natalie wrote:
Siemel Naran wrote:
Can Derived class static member access protected member from base class?


No. Same reasons why it doesn't for a non-static member.


Um, isn't the very definition of a protected member that it can
be accessed by classes derived from the base?

I'm thinking the code may well be as seen in OP... :-)
Jul 22 '05 #3
"Micah Cowan" <mi***@cowan.name> wrote...
Um, isn't the very definition of a protected member that it can be
accessed by classes derived from the base?


It's a bit more complicated than that. The issue of protected
access and how it sometimes "doesn't work" has been discussed so
many times here and in c.l.c++.moderated that it doesn't really
make sense to begin again.
Jul 22 '05 #4
Victor Bazarov wrote:
"Micah Cowan" <mi***@cowan.name> wrote...
Um, isn't the very definition of a protected member that it can be
accessed by classes derived from the base?

It's a bit more complicated than that. The issue of protected
access and how it sometimes "doesn't work" has been discussed so
many times here and in c.l.c++.moderated that it doesn't really
make sense to begin again.


Mm, never mind, I've spotted my thinko now.
Jul 22 '05 #5

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

Similar topics

3
by: Kirk Marple | last post by:
Just want to see if this is 'by design' or a bug... I have a common List<T> defined in a base class, and the base class has a static property to...
3
by: Jasleen | last post by:
I want to access the protected member hresult of the Exception class, so I derived my own class from ApplicationException and SystemException. ...
14
by: Edward Diener | last post by:
In C++ one can change the access level in a derived class by the "using" keyword. So, for instance, a public method in a base class can be made...
3
by: keith.thornhill | last post by:
hey all, got a problem here using Visual basic .net 2005 i have two pairs of base/derived classes. lets call them Base/Derived and...
15
by: Bob Johnson | last post by:
I have a base class that must have a member variable populated by, and only by, derived classes. It appears that if I declare the variable as...
15
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I met with a strange issue that derived class function can not access base class's protected member. Do you know why? Here...
4
by: softwaredoug | last post by:
Here is some test code I've been attempting to compile (Visual Studio 2003) test.h: class Base { protected: Base() {} public:
3
by: Edan | last post by:
I have a base class with protected members (`Base`). The function `MakeBase()` is a member function of another class, that returns a `Base` object...
10
by: blangela | last post by:
If I pass a base class object by reference (likely does not make a difference here that it is passed by reference) as a parameter to a derived...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.