Questions tagged [protected]

`protected` is an access specifier in object-oriented languages. When the members of a class are `protected`, there is restricted access to these members for other classes.

The protected keyword specifies access to class members in the member-list up to the next access specifier (public or private) or the end of the class definition. Class members declared as protected can be used only by the following:

  • Member functions of the class that originally declared these members.
  • Friends of the class that originally declared these members.
  • Classes derived with public or protected access from the class that originally declared these members.
  • Direct privately derived classes that also have private access to protected members.
  • In the Java language, classes in the same package as the class that originally declared these members.
1204 questions
0
votes
1 answer

Understanding the behavior of protected members in class

I am trying to understand the behavior of protected member in a class. I have a class TopClass which contains protected integer pr. Class: package com.test; import com.test.anotherpackage.SubClass1; import com.test.anotherpackage.SubClass2; import…
D3V
  • 1,543
  • 11
  • 21
0
votes
1 answer

Overriding a protected method

I have a protected method in superclass. package com.pts.filter public class a { ... protected Filter callFilter(Object aInParam) { return Filter.LowPass; } } I am extending the class a. package com.pts.filter.image public class b…
as3rdaccount
  • 3,711
  • 12
  • 42
  • 62
0
votes
1 answer

class not retainining protected values

I've looked at existing answers for my problem. I've echo'd the value right through the process and right up until the "header('Location" instruction the values remain intact. I don't think it's a serialization problem as suggested for similar…
Jane Alford
  • 51
  • 1
  • 2
  • 10
0
votes
0 answers

Can you call a protected method inside a overwrite private virtual?

I having a link error (unresolved external symbol) for a protected method (not virtual) being called in a virtual private method that I'm overwriting. The link error is solved by changing protected to public? I didn't found any info on that. Things…
Icebone1000
  • 1,231
  • 4
  • 13
  • 25
0
votes
1 answer

Updating row directly in ASP.NET using databind() ! Please help me

This is a difficult problem so I found how to solve when cell on table don't receive input value from user . Please show me how retrieve value from updated cell . Please help me . I am very boring because of seeing this problem protected void…
0
votes
1 answer

C# protected override void "Does not exist in current context"

I have a class in which I override OnPaint for the control Button, and it gives me an error that Graphics G does not exist in current context yet I have Graphics G defined. abstract class ThemeContainer154 : Control { #region " Initialization…
user1422473
  • 117
  • 1
  • 3
  • 9
0
votes
1 answer

Stubs access to the protected variables

I need to test this class: public abstract class GaBase { protected GoogleAnalyticsInfo GAInfo; protected abstract void PopulateGAInfo(); public string GetGoogleAnalyticsTag() { //Return any info related to GAInfo } …
Kapoue
  • 847
  • 2
  • 11
  • 15
0
votes
1 answer

Wordpress password protected posts generate error 403

I password protected a Wordpress post. When I enter the right password for the post, I get a 403 error instead of getting access to my post content. When typing a wrong password, I also get that 403 error. This is what the .htaccess (at the root of…
Corinne
  • 2,035
  • 3
  • 17
  • 15
0
votes
5 answers

Java - protected 'getters' vs. nested classes

If I have a bunch of fields in a parent class that all need to be inherited by subclasses, is it better to have the subclasses nested in the superclass, make the fields protected rather than private, or use protected accessors? Or some other…
false_azure
  • 1,333
  • 4
  • 25
  • 46
0
votes
2 answers

Prevent ObjC "abstract" class' init method from being called while allowing [super init]?

Say I have a pseudo-abstract base class that users should not instantiate. Basically I want to throw a warning when they're trying to call init on the class, or return one of the concrete instances with default values. However, the concrete…
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
0
votes
1 answer

In java protected membes access from diff package

In Java, how can I access protected members in a different package? package p1 class base protected int x package p2 import p1.* class derived extends base int x class subderived extends derived int x From…
0
votes
5 answers

C++ run time error with protected members

I am trying to do a homework assignment where we insert a string into a string at a specified point using a linked stack, hence the struct and typedef. Anyway, when I try to access stringLength in the StringModifier class inside the InsertAfter…
Nickolas
  • 1
  • 2
0
votes
1 answer

ZF2 Extract headers from response

I make use of cURL with zend framework, it gives me back the headers and site content. I use this output in another class where I want to extract the headers from the curl output to see if a language is ser (content-language). The output has…
directory
  • 3,093
  • 8
  • 45
  • 85
0
votes
2 answers

scala: class members only accessible from subclass AND the subclass MUST in the same package. How?

object P{ object P1{ class A{ //I want only classes/objects that extends A AND in the package P1 can access x //It means, the modifier `protected` and the qualifier [P1] is combined with operator `AND`: //protected AND [P1]…
0
votes
2 answers

How to access Joomla protected property?

I have tried this and it's working:
Vicheanak
  • 6,444
  • 17
  • 64
  • 98