private

Delphi 'private' clause (directive) does not work

自闭症网瘾萝莉.ら 提交于 2019-12-24 16:17:22
问题 I'm trying to check if my private procedures are really private. But it works the way it shouldn't. Please help me, maybe I missed something about how the incapsulation should work. This code should not work. I guess. But it works. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type tmyclass = class private procedure one; end; TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private

Swift 4: type(of: self) differs when using private/fileprivate

大兔子大兔子 提交于 2019-12-24 14:43:16
问题 I implemented an extension to NSObject to get the dynamic type of my objects: extension NSObject { var dynamic_type : String { get { return String(describing: type(of: self)) } } } This works perfectly for public classes. In a class called InitialState dynamic_type would be "InitialState" (this is what I want) But as soon as I change the class to private or fileprivate it is something like "(InitialState in _AF5C6D4A3B423A6F0735A7740F802E5A)" (the parenthesis are also returned) Why is this

Ways to create a singleton with private variables?

风格不统一 提交于 2019-12-24 08:48:08
问题 I'm trying to create a singleton that has variables not directly mutable from the outside. This is my current code: var singleton = new (function () { var asd = 1; this.__defineGetter__("Asd", function() { return asd; }); })(); alert(singleton.Asd) // test However, it seems like alot of ugly code just to achieve a simple thing. What are some cleaner alternatives to create a singleton with such private variables? 回答1: I think only closure can bring real private variable in JavaScript. Usually

Private Boolean: how to set on SKCropNode, with Swift?

六月ゝ 毕业季﹏ 提交于 2019-12-24 08:12:26
问题 SKCropNode works by removing every thing from its affected nodes that are not covered by its source image. This is one type of masking, the other is to invert this logic, and reveal everything that's not covered by the source image. SKCropNode has a boolean switch to set this state, called invertMask , sensibly enough. What's annoying is that it's seemingly private. If putting aside all the app store approval processes, dangers of private APIs, etc, and accepting that it's something

Making static class members threadprivate in OpenMP

匆匆过客 提交于 2019-12-24 07:49:52
问题 I'm working with OpenMP in C++ and try to make a static member variable of a class threadprivate. A very simplified example code example looks like this #include <omp.h> #include<iostream> template<class numtype> class A { public: static numtype a; #pragma omp threadprivate(a) }; template<class numtype> numtype A<numtype>::a=1; int main() { #pragma omp parallel { A<int>::a = omp_get_thread_num(); #pragma omp critical { std::cout << A<int>::a << std::endl; } } /* end of parallel region */ } If

Java RMI: How can I restrict RMI method to only be called internally by the client object

左心房为你撑大大i 提交于 2019-12-24 07:29:35
问题 I have an RMI model which uses a thread on each side (Client/Server Side) to maintain a client heartbeat. If the client crashes without unlocking the server, the lock will eventually timeout. I don't want the user of my client API to be able to call the methods that deal with the heartbeat/lock. However from my understanding of Java RMI, the client and server must implement a common interface which defines all the methods that I want RMI access to, and these methods must be public. Since the

Java RMI: How can I restrict RMI method to only be called internally by the client object

旧街凉风 提交于 2019-12-24 07:29:09
问题 I have an RMI model which uses a thread on each side (Client/Server Side) to maintain a client heartbeat. If the client crashes without unlocking the server, the lock will eventually timeout. I don't want the user of my client API to be able to call the methods that deal with the heartbeat/lock. However from my understanding of Java RMI, the client and server must implement a common interface which defines all the methods that I want RMI access to, and these methods must be public. Since the

How can I write generalized functions to manipulate private properties?

你离开我真会死。 提交于 2019-12-24 03:59:10
问题 In Matlab, I would like to perform some operations on private members of a class. I would also like to perform this exact same task on other classes as well. The obvious solution is to write a function in a separate M file that all the classes call in order to perform this task. However, that seems impossible in Matlab (see below). Is there another way to accomplish this? Here is the problem specifically: suppose I have one m file with the contents classdef PrivateTest properties (Access

Actual implementation of private variables in python class [duplicate]

让人想犯罪 __ 提交于 2019-12-24 02:56:28
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: The meaning of a single- and a double-underscore before an object name in Python I had a question when I was reading the python documentation on private variables link. So the documentation tells that it is a convention to name private variables with an underscore but python does not make the field private. >>> class a(): def __init__(self): self.public = 11 self._priv = 12 >>> b = a() >>> print b._priv >>> 12 I

How can a class method access a private member of another instance of the same class?

拥有回忆 提交于 2019-12-24 02:07:40
问题 I cannot understand the code in jdk1.7. value is private, so why can the code use it with e.g. anotherString.value ? public final class String implements java.io.Serializable, Comparable<String>, CharSequence { /** The value is used for character storage. */ private final char value[]; /** Cache the hash code for the string */ private int hash; // Default to 0 public int compareTo(String anotherString) { int len1 = value.length; int len2 = anotherString.value.length;//cannot understand int