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
-1
votes
3 answers

Java's protected doesn't protect

Java's protected members declared in class are visible in the whole package. Why? I simply want to share privacy between my class and it's subclasses but Java doesn't allow me. What I am supposed to do?
user2591935
  • 299
  • 1
  • 14
-1
votes
2 answers

Unable to access protected member from derived class

I have a setup something along the lines of this. Multiple levels of inheritance from a single base class containing a protected member x. class Sprite { protected: float x, y; } class AnimatedSprite : Sprite { public: void draw(float x,…
-1
votes
1 answer

Android Downloaded HTML content should not coping using file managers / through the USB connection

I'm developing a android application which is downloading contents from a API as a zip file and extract it in to the assets folder in the app.Then using the web view in the app can load that content. How can i prevent user from directly access the…
-1
votes
1 answer

Allow Users To View Formula Bar If Worksheet protected

Sometimes ago I faced with the following problem: I have protected Worksheets and formulas in cells. So, I haven't opportunity to view formulas in formulas Bar(with lighting). Thereby, does it really to allow users view formulas in formulas bar if…
Chrome63
  • 1
  • 1
-1
votes
2 answers

C++ Isn't this a useless inline declaration?

This is another question about inlining a function. But I will take possible comments and answers right away: Defining a function inside a class makes it inline automatically. The same behaviour can be achieved by marking a function with…
Noel Widmer
  • 4,444
  • 9
  • 45
  • 69
-1
votes
1 answer

Assigning an argument of a class(a) to another class's(b) variable by calling class(b) constructor

What I need to do: //Constructor that initializes b to inVal1 and the inherited a // to inVal2 by using the BaseExample constructor. public DerivedExample(int inVal1, int inVal2); How do you call the class BaseExample's variable, in class…
userb
  • 173
  • 2
  • 15
-1
votes
2 answers

Defining a protected method of custom return type within a derived class?

Using C++ and trying to write a method which returns an entity of type thing which is defined as protected in its parent class but getting the following error: 'thing' does not name a type class A { protected: struct thing{ }; }; class B :…
Jazcash
  • 3,145
  • 2
  • 31
  • 46
-1
votes
2 answers

Why can protected attributes be accessed by other classes of the same package

Why do protected attributes in a Java class can be accessed by the other classes of the same package ? I thought it was only accessible through inheritance. A.java package abc; class A { protected int attr1; } B.java package abc; class B { …
Libert Piou Piou
  • 540
  • 5
  • 22
-1
votes
2 answers

Accessing protected class in java

I have an object represented as follows: public final class FooFunc
frazman
  • 32,081
  • 75
  • 184
  • 269
-1
votes
1 answer

Wordpress plugin for protected forums?

I would like to create a forum using Wordpress. The forum needs to password protected to only allow certain users to access the forum. And the users will have different permissions, all users would be allowed to post but only after an admin has…
Kane Mitchell
  • 370
  • 2
  • 4
  • 12
-1
votes
1 answer

Protected fields and generics

I have an abstract class MotorFahrzeug and an extending class LKW as shown below. I wrote a generic class with type parameter implementing a comparator. I'm wondering why the method compare( T m1, T m2 ) in this generic…
Steve
  • 7
  • 3
-1
votes
1 answer

Want to protect file from copy,download

I have following requirement. Admin can upload any files like jpg,pdf,PPT,DOC file on server. End User or viewer only access the files in display/view mode. User shouldn't to be allowed to copy/paste/download/print/modify files. Please suggest me…
Pravin
  • 95
  • 18
-1
votes
4 answers

C++ Accessing a protected variable in class A from class C, where C is subclasses of B, which is a subclass of A

My question really says it all but i'll just reiterate the problem. In class A there is a protected variable I am trying to access (a vector). Class B is a subclass of class A and, in its constructor, can access and add to this vector as it…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
-1
votes
2 answers

Accessing protected using super

I have following code package com.kathy.accessmodifiers2; public class base extends Object{ protected int a = 10; } package com.kathy.accessmodifiers; import com.kathy.accessmodifiers2.*; class derived extends base { public void D() { …
Naresh C
  • 63
  • 3
  • 9
-1
votes
2 answers

protected stream operator in an abstract class

I have seen a few examples of abstract classes with a friend operator<< and a virtual "print" member function where the two declarations are both in the protected section. For example: class Function{ public: virtual ~Function() {} virtual…
Dan Dv
  • 473
  • 3
  • 12