Questions tagged [public]

`public` is an access-specifier in object-oriented languages; it indicates that all objects have access to the `public` field or method.

In object-oriented languages, classes specify how much access other classes can have to their members.

When a member has the public specifier, other classes have full access to that member.

Other access specifiers are protected and private.

You can use this tag for questions about how the public specifier controls (or fails to control) access to the members of a class, and questions on how it interacts with the other access specifiers.

1633 questions
0
votes
3 answers

C++ inheritance: Can't access private element of base class

I have a base class: class Base { public: functions... private: std::vector privateElement; } and a derived one: class Derived : public Base { public: functions... Derived(anotherElement) : privateElement(anotherElement) …
BlackMamba
  • 1,449
  • 2
  • 12
  • 18
0
votes
1 answer

Nodes declared in private

I haven't programmed in C++ in forever and am really rusty. Help me out please? I've been tasked to develop a reversible singly linked listed but the nodes have to be declared in private. How do I access them to push/pop off my stack. Or am I going…
0
votes
3 answers

Storing a worksheet name for use in another sub

I'm using one sub-procedure to store filepaths/workbooks and worksheets in Public variables which can then be accessed by other sub procedures in the module. Here is some example code: Public myfp As String Public mywb As Workbook Public myws As…
Rapid
  • 1,442
  • 1
  • 13
  • 25
0
votes
2 answers

meteor release 0.6.5 public/images looks like it's packaging up in the wrong directory

In my meteor application I create a directory public/images and then I place image files there. Then I watch .meteor/local/build/programs/app see that I now have the new directory .meteor/local/build/programs/app/images. the public directory is…
ksondere
  • 31
  • 1
  • 2
0
votes
2 answers

Having simple difficulties with encapsulation

I'm new to programming and I have this script that I'm making, it makes a function that reads XML files based on your input, I've just ran into this issue though where I cannot access the variable named "XMLtext", it's public, can someone tell me…
user2690614
  • 11
  • 1
  • 4
0
votes
0 answers

Create RSA keys with good SYNTAX

How can I generate proper RSA keyfiles with correct syntax? Best would be soluction in javascript. I have already generated numbers for 512bit key: e = 00065537 d =…
0
votes
3 answers

Java public variable multiple classes

I was curious what public variables actually do. I assumed they work across all classes inside of a package, but apparently that is not the case. I want to know how to carry the ADD, and MULT variables over from the first class into the second…
Austin Gibb
  • 303
  • 1
  • 4
  • 12
0
votes
2 answers

C#: Isn't using properties instead of public variables to cumbersome?

Beginners question: Is there any disadvantage to the following solution? public string SomeProperty { get; private set; } as in C# public variable as writeable inside the class but readonly outside the class Because I definetly find it nicer,…
user1323995
  • 1,286
  • 1
  • 10
  • 16
0
votes
1 answer

VBA If statements with public variables error type mismatch (error 13)

I think this is probably a quick fix but its been stumping me all morning. I have defined many variables as public at the top of the vba project (any variables ending in "yn" are String, and the rest are Variant or Single). Different subs…
user2623046
  • 43
  • 1
  • 1
  • 4
0
votes
1 answer

Classes, Privates through Publics

i am trying to understand how can i access private classes through public classes because some experts said to me that i have to use only private classes. But i can't understand why this doesn't work.I really don't know how can i access private…
Manuel Pap
  • 1,309
  • 7
  • 23
  • 52
0
votes
2 answers

Making Controls public/Global in Netbeans with Java

So I have multiple forms for my current project and I have made classes that interact and do some utility work behind these forms. However I am unable to access controls on other forms. Say I have a text control on Form A and I want to use a class…
0
votes
2 answers

Money edit box with 2 decimal places

MVC4, Code First, C# project When populating a money field with either a explicit value or from a table read the TextBoxFor displays the value with 2 decimal places. If the field is populated from a money field in another class it displays 4…
Joe
  • 4,143
  • 8
  • 37
  • 65
0
votes
1 answer

Error Inconsistent accessibility - C#

sorry for my bad english in advance.I'm making a game for a proyect in uni and got stuck in this part where i have to save all the player names per game in a collection. So i got these two classes class Score { ... } class ScoreList { public…
0
votes
4 answers

Reaching public property of parent class

a simple question : public class class1 { public string string1; public class class2 { public string string2 { get{ string tmp = class1.string1; } } } } I want to be able to reach…
EngelbertCoder
  • 777
  • 2
  • 9
  • 29
0
votes
3 answers

Pointer to a class access public member function

How does below program prints "Show Called" ? I guess it should have been run-time error since value of obj ptr is NULL. #include using namespace std; class ex { int i; public: ex(int ii=0):i(ii) {} …
Rohit
  • 6,941
  • 17
  • 58
  • 102