Questions tagged [public-members]
18 questions
37
votes
7 answers
Why make private inner class member public in Java?
What is the reason of declaring a member of a private inner class public in Java if it still can't be accessed outside of containing class? Or can it?
public class DataStructure {
// ...
private class InnerEvenIterator {
// ...
…

vitaut
- 49,672
- 25
- 199
- 336
25
votes
4 answers
Why am I able to have a public member in a non-public class?
class MyClass
{
public static final int num=90;
}
Why am I allowed to create a public member in a non-public class?
Is there another way of accessing this member that I do not know of (other than through the class name)?

XForCE07
- 1,176
- 1
- 10
- 10
14
votes
1 answer
Can't use public nested class as private method parameter
In the following code:
class Outer {
private:
void f_private(Outer::Inner in); // Wrong
public:
class Inner {};
void f_public(Outer::Inner in); // OK
};
f_private() cannot use nested class Outer::Inner as parameter type. But it's…

Neo
- 1,031
- 2
- 11
- 27
5
votes
1 answer
How can I scope this "public" method correctly?
I have this code (JSFiddle)
var OBJ = function(){
var privateVar = 23;
var self = this;
return {
thePrivateVar : function() {
return privateVar;
},
thePrivateVarTimeout : function() {
…

El Ronnoco
- 11,753
- 5
- 38
- 65
4
votes
2 answers
Public vs Private in Typescript Constructors
Am I right that public members in a TypeScript constructor are public in the class and that private members are private?
If so, what is the effective difference between public members and properties?
Assuming that the difference is that properties…

Jesse Liberty
- 1,314
- 1
- 11
- 26
3
votes
1 answer
.NET Reflector - Reflexil, Change private to public
I have an assembly loaded into .NET reflector and I have the reflexil addin.
I found a method in the assembly but it's private. Copying the whole method to my code is too much work because it uses many other methods in the assembly. I just want to…

Kirk
- 89
- 1
- 5
3
votes
1 answer
Making a method public in JavaScript. Why this syntax?
I was studying TinyMCE code and stumbled upon this way of exposing public methods:
tinymce.extend(this, {
execCommand : execCommand,
queryCommandState : queryCommandState,
queryCommandValue : queryCommandValue,
addCommands :…

Andy
- 2,670
- 3
- 30
- 49
3
votes
9 answers
lazy load public class data member in PHP
I want to lazy load the public data members of a class in PHP. Assume we have the following class:
If $name, $age and $status_indicator were private data…

user4o01
- 2,688
- 4
- 39
- 54
2
votes
2 answers
Freemarker: access public field with no getter in template
I'm setting up views in a Dropwizard app and ran into a curious issue with Freemarker.
Following the docs here I set up a very simple example as follows
public class ExampleFreemarkerView extends View {
private Foo foo;
public…

davnicwil
- 28,487
- 16
- 107
- 123
2
votes
4 answers
Why aren't all fields/properties/methods public?
I know this may sound stupid, but i really want to know :)
im learning c# currently,
and as you know you need to set "object"(button,label,text,variable, etc.) public or whatever you like.
However, you still need to write a code like this:
// my…

user646317
- 47
- 3
- 9
2
votes
1 answer
Declaring private variable in Python
I am writing a banking application in Python, and reading some source code from here Banking Application. The balance class is defined below:
class Balance(object):
""" the balance class includes the balance operations """
def…

python
- 4,403
- 13
- 56
- 103
1
vote
1 answer
How to access public members in private method in R6Class?
library(R6)
Person<-R6Class("Person",
public=list(
name=NULL,
age=NULL,
initialize=function(name,age){
self$name<-name
self$age<-age
},
GrowUP1=function(){
self$publicGrow()
},
…

beginner
- 13
- 6
1
vote
2 answers
Creation of a stored procedure requires a package in Oracle
Below is some PL/SQL which is intended to create a very simple stored procedure in Oracle, based on code generated via SQL Developer IDE. I'm receiving the error when I run the command. On many tutorials online, the instructions for creating…

JustBeingHelpful
- 18,332
- 38
- 160
- 245
0
votes
3 answers
C++ | Derived class is accessing private members of the base class rather than its own private members
sorry if this is an obvious one but I've searched around and I'm still unclear about how to solve this issue. Here is my code:
#include
#include
using namespace std;
class PermMagnet {
public:
string name;
int…

Cato
- 29
- 5
0
votes
1 answer
Can't acces super class public members with sub class variable
So if I have a following class Super:
class Super {
public:
string member = "bla bla";
void doSth() { cout << member; }
};
And a class Sub that inherits Super:
class Sub : Super {
public:
string member2 = "bla bla 2";
};
Than, when I…

Scarass
- 914
- 1
- 12
- 32