Questions tagged [private]

Private is a way of encapsulation in object-oriented programming.

Private is a way of encapsulation in object-oriented programming.

2890 questions
1
vote
2 answers

Assigning class constructor arguments private variables in coffeescript

I've found that I can use private variables in coffeescript classes like so: class Book title = null numberOfPages = null constructor: (t, nop) -> title = t numberOfPages = nop ripOutPages: (numPages) ->…
tomphp
  • 307
  • 1
  • 4
  • 10
1
vote
1 answer

Base Class and Derived Class private member variable usage

I've developed a compiling bank system of different accounts. My base class is Account, and derived classes are Checking, Savings, MoneyMarket. The latter three inherit private member variable 'balance' from Account. All four accounts need to…
Student
  • 11
  • 2
1
vote
1 answer

How to deal with public/private pair in this binary trees?

The problem is to add a method to this class that reads from a scanner and constructs a tree with the data from the scannerin preorder fashion. //the class to add the method readTree to public class IntTree { private IntTreeNode…
committedandroider
  • 8,711
  • 14
  • 71
  • 126
1
vote
0 answers

How to unmarshall XSD fields to private fields instead of protected using xsd OR xjc parameters

Is there any way, xsd tags for instance, to unmarshall xsd files to get private fields with accessor methods instead of protected fields which is the default behaviour? I have tried to search in the documentation but no avail. I am aware of the…
Mike
  • 397
  • 2
  • 16
1
vote
2 answers

One attempt of private methods in JS

I've seen people trying to attempt implementation of private methods in JS. However they all have different issues, like this one: JavaScript private methods I believe my attempt has some problems as well. But other than the overhead and caller is…
rabbit.aaron
  • 2,369
  • 16
  • 25
1
vote
2 answers

Why is access control useful?

I've read the section concerning access control in the iBook published by Apple, but I'm not understanding why is that needed or useful. Why would I need to hide parts of my code to the other code files in my app using private?
dieortin
  • 514
  • 5
  • 16
1
vote
4 answers

How to make a private variable in a public method

I have a public method but there is a variable inside that I don't want other classes to access. Could I do that like this? public static void example() { private { String privateString = "Can I do it like this?"; } } Thanks.
Silvr Swrd
  • 59
  • 1
  • 1
  • 4
1
vote
1 answer

iOS: Allowing Only A Certain Class Access to a Specific Private Method in another Class?

I have a few public and price methods in Class A. I use the same methods in Class B, but rather than copy and paste these methods in both classes, I want to access Class A's private methods from Class B. The problem is I don't want any other class…
KingPolygon
  • 4,753
  • 7
  • 43
  • 72
1
vote
5 answers

Confusing Private variable access

Can private variable of one instance be available in the function of other instance. The following code is printing 5 #include class A { public: A(int value) { x = value; } void printValue(A *obj)…
singingsingh
  • 1,364
  • 14
  • 15
1
vote
1 answer

Using "protected" instead "private" - Action Script 3

I'm using ASDocs to make something like a "help" for my code and the problem is PRIVATE methods are omitted on ASDocs. The thing is, on my project, I don't see any problems in change what is PRIVATE to PROTECTED. If I do that, the docummentation…
1
vote
6 answers

Protected member Vs private member in inheritance java

I have an abstract class Entity and then multiple instance can extend Entity like A extends Entity { } B extends Entity { } Now all the entity needs to have entityId So should I have entityId as a private field in Entity and set it via the…
user1479802
  • 201
  • 3
  • 12
1
vote
0 answers

How UIWebvew like Mobile Safari's private mode, can I operate?

How UIWebvew like Mobile Safari's private mode, can I operate? I've read the search page of Google and Apple's documentation then, I not found history clear for UIWebview. I Tried delete cookie and remove cache. but it was not operation.
1
vote
1 answer

Git - Having a private local "fork"

I wish to make some private customizations to a public open-source project from GitHub, How should I make a "private local fork" of it? Just clone it to my computer and commit locally, or there's another type of Git command which fits the process…
Taru
  • 2,562
  • 4
  • 22
  • 30
1
vote
5 answers

Access private static method from outside the class C++

How exactly can you access a private static method from outside the class. Say, I have a class Class ABC { private: static void print(string str) { cout << "It works!!!" << endl; } }; Now, I just to call…
rathorsunpreet
  • 101
  • 1
  • 5
1
vote
1 answer

c++ class private access modifiers

I have this question about c++ class access modifiers. If I have a basic class, let say it looks like this: class A { public: int a1; private: int a2; } If i create another class, called C that has public access from class A, then the…
1 2 3
99
100