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
2 answers

Free access to protected member

I create a class, that has a few protected members, that are completely accessible to other classes: class MyClass { protected String name; } In my opinion, this shouldn't compile: MyClass mc = new MyClass(); mc.name = "foo"; but it works…
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
0
votes
0 answers

All class files in one package

So I added mod/plugin support in my java game. But I don't want give users allowance to every public variable, classes, and methods. I have used protected where I can. But in some cases It's impossible. I have been thinking of putting all classes…
Yemto
  • 613
  • 1
  • 7
  • 18
0
votes
1 answer

how to protect an activity in android

I want to protect my activity class to not be allowed to use in another package, for example if have a user homepage activity it is should be able to called only if the user signed in correctly, but the protected is not allowed in android, so how i…
Mohammad
  • 3,449
  • 6
  • 48
  • 75
0
votes
1 answer

Get Result of Private Property TcpClient.BeginConnect, IAsyncResult in VB.NET

I have an application in VB.NET When I run the application in Visual Studio 2010 and mouseover an IAsyncResult, I see the protected property Result. I would like to read the value of the property in the application. How can I do that? Imports…
Jacob Quisenberry
  • 1,131
  • 3
  • 20
  • 48
0
votes
3 answers

Calling a protected method for a member object in C++

If i have two classes, for example like this class A { ... protected: B* test; aFunction(); }; class B { ... protected: A* test1; public: bFunction(); }; can I do this inside bFunction() of…
idjuradj
  • 1,355
  • 6
  • 19
  • 31
0
votes
3 answers

AS3: overriding protected var in subclass

I'm having a blackout here. I thought I understood these principles, but I can't seem to get it working anymore. I want to let a DeleteButton inherit from a general Button class. This DeleteButton should alter the protected padding values and have a…
Decent Dabbler
  • 22,532
  • 8
  • 74
  • 106
0
votes
1 answer

.bat file to use a list of characters as a password

I am looking for some help/guidance on creating a .bat file to pass a list of characters into a password dialog box in Excel. In other words, I know that the password is 3 characters long (26^3 possibilities). I tried using WorkSpace Macro Pro to…
0
votes
1 answer

Is There Any Capacity or Security matter With Class Formats?

I Know the Difference between Public/Private/Protected/Static and other Formats of class. But It's my Question.Is there any matter with security or Capacity of File for using Public? If is not...Why do not always use Public? What is The usage? in…
Amin AmiriDarban
  • 2,031
  • 4
  • 24
  • 32
0
votes
3 answers

Why is my score variable not assessable outside my GameScreen class?

DIFFERENT CLASSES package battleship; public class GameSum extends javax.swing.JFrame { public GameSum() { initComponents(); J_time.setText(score); } package battleship; public class GameScreen extends…
0
votes
2 answers

Accessing Protected Variable Of An Instance Of A Class That Extends An Abstract Base Class?

I have an abstract class called MyAction which contains a protected enum variable. The class is defined as follows: package mypackage; public abstract class MyAction { public enum ActionId { ACTION1, ACTION2; } protected…
Jan Tacci
  • 3,131
  • 16
  • 63
  • 83
0
votes
1 answer

Joomla 3.0 administration protection remove iframe

I have more joomla pages, and i must work at the same time on more admin. panels, so i have created a page where i load pages in iframe, but joomla admin. area is protected from iframe, know someone how can i deactivate this protection? If i try to…
Marco P.
  • 9
  • 2
0
votes
1 answer

how to get the overriden version of a protected method in java through reflection?

Lets say I have a class called SuperClass: public class SuperClass { protected void TheCake() { System.out.println("The cake is a lie"); } } and another called SubClass: public class SubClass extends SuperClass { @Override …
user2212990
  • 177
  • 1
  • 9
0
votes
2 answers

How to deny users to create an instance of a parent object in Python

Let's say I create a parent class named Ball. As child classes I then continue to create Basketball, Baseball and Tennisbal. However I would not like my users to ever create an instance of Ball because it is not specific enough. I would like to…
Aeronaelius
  • 1,291
  • 3
  • 12
  • 31
0
votes
3 answers

PHP protected variable

Is there anyway to make an variable to protected and can't overwrite to php ? p.s: Not in class or define. For example; I want this code return "something" not "test". Do you have any idea about…
merdincz
  • 427
  • 4
  • 16
0
votes
2 answers

C++ protected heritage

I have an abstract class AUnit with variables and getters/setters in virtual pure like this class AUnit {int var... int getVar() const = 0 ... } All the data is in protected: except constructor and destructor. I have Berserk and Tank as child like…
Khelben
  • 23
  • 1
  • 4