Top "Private-members" questions

In object oriented programming, private members are those data fields, properties, or methods of a class that are only accessible from within the class itself.

C++ Accessing a private member in a friend class

I have 2 classes (firstClass and secondClass) which firstClass is a friend of secondClass, and has a private nested unordered_map, …

c++ private-members friend-class
Are private fields inherited by the subclass?

I have read that a subclass cannot inherit private fields or methods. However, in this example class SuperClass { private int …

java inheritance private-members
Java setting private fields inside constructors

Common design practice is to make instance variables private and have public getters and setters to access them. But many …

java constructor private-members
override "private" method in Python

Consider a class with a "private" method such as: class Foo(object): def __init__(self): self.__method() def __method(self): …

python oop methods subclass private-members
Should I document my private methods?

Private methods documentation can only be seen by who has access to the source code. Is it worth the effort …

documentation private-members
Private functions and Variables ExtJs4?

In my current project I am using ExtJs3.3. I have created many classes which had private variables and functions. For …

javascript extjs private-members extjs4
Test a public method which calls a private method using NUnit

I have a public method in a class that internally calls a particular private method within that class. It looks …

c# unit-testing nunit private-members nmock
Using Moq to verify execution of private methods

I want to test the following logic (this is obviously a stripped-down version of my method): public void myPublicMethod(params) { …

unit-testing mocking moq private-members
Make a property that is read-only to the outside world, but my methods can still set

In JavaScript (ES5+), I'm trying to achieve the following scenario: An object (of which there will be many separate instances) …

javascript getter private-members defineproperty
Why is it allowed to access Java private fields via reflection?

Consider this example : import java.lang.reflect.Field; public class Test { public static void main(String[] args) { C c = new …

java reflection private-members