instance-variables

How to call instance variable form another class and file

邮差的信 提交于 2019-12-24 20:36:54
问题 I have a question, I have 4 file app.py , face.py , camera.py and db.py Inside face.py file I have one variable call known_encoding_faces . If I put print code inside my face.py and run the app.py the result will display in my command prompt. My question is how can i use known_encoding_faces variable in my camera.py? My expected result is when i run my app.py and open my webcam the command prompt will show the printed known_encoding_faces output. I believe if this work means this known

PHP OOP Performance : Parameter or Instance Variable? [closed]

你说的曾经没有我的故事 提交于 2019-12-24 17:53:29
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Im curious about getting an answer for a OOP question but can't find any info so far. Here goes, writing classes and methods is it

Access instance variables from an activity inside a AsyncTask

南楼画角 提交于 2019-12-24 11:25:15
问题 I have an AsyncTask (in a separate file) which is invoked on an activity. When I instantiate the AsyncTask, I send the activity as a param. How can I access the acitivity's instance variables from the onPostExecute method of the AsyncTask? Thanks! 回答1: You must be careful when passing an Activity or Context to an AsyncTask that is not an inner (non-static) class of an Activity - this is because in this case the lifetime of the Activity / Context and the AsyncTask are different, and if you

Difference between self.variable and variable [duplicate]

痴心易碎 提交于 2019-12-24 10:39:20
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Difference between class property mVar and instance variable self.mVar I am new to developing in Objective-C and I couldn't quite figure out what the difference is between the following: First let me explain my situation. I've got an NSMutableArray , and I created and outlet for it in my .h file. Now when I assign an array to it as self.myMutableArray=myArray I get an error; However just myMutableArray=myArray

PHP Equivalent to Ruby's @instance_variable?

走远了吗. 提交于 2019-12-24 02:37:04
问题 I was wondering if there is a shorter, better or cleaner way to assign and use class variables in PHP, then through $this->instance_variable ? class Bar { # internal variables var $foo = "Hello World"; public function foo() { return $this->foo; } } I am not very familiar with all PHP's variable scoping, but from what I understood at the official docs, you can either define them global, or access them trough $this-> ? Is there a keyword to define them as instance variable, so they are

When I instantiate a class in PHP, do I get a pointer to the object?

为君一笑 提交于 2019-12-23 20:15:35
问题 Or, does my variable hold the object itself? When I say for example: $obj = new ClassOne(); is the $obj a pointer to the object created in the memory? Does it hold only the memory address to the object? Or does it hold the object itself? For example when I say, $obj = new SomeOtherClass(); Will ClassOne object be garbage collected like in JAVA, or will it cause a memory-leak like in C++? 回答1: Briefly, the object models in C++ and Java are a bit different: C++ has unconstrained variables:

Can Ruby subclass instance variables _overwrite_ the superclass's (same name)?

心不动则不痛 提交于 2019-12-23 12:34:46
问题 In the Chapter 7.3.5 "Inheritance and Instance Variables" of the book "the ruby programing language" says : Because instance variables have nothing to do with inheritance, it follows that an instance variable used by a subclass cannot “shadow” an instance variable in the superclass. If a subclass uses an instance variable with the same name as a variable used by one of its ancestors, it will overwrite the value of its >ancestor’s variable. This can be done intentionally, to alter the behavior

C/C++ Possible to get a “list” of instance members by querying a class?

自作多情 提交于 2019-12-23 06:56:46
问题 Suppose we have a struct in C++: struct foobar { int age; bool hot; String name }; Is there a way, programatically, to query the above struct to extract its instance members? For example: String[] members = magicClass.getInstanceMembers(foobar); Members would have ["age", "hot", "name"] as it's values. Possible? The reason why I ask is because I have structs that change over time (variables added/removed). I want to be able to create auto-generating Lua files with this saved data. Thanks 回答1:

What is the point of calling “@synthesize slider = _slider;”

空扰寡人 提交于 2019-12-23 03:33:15
问题 Can someone explain to me the significance of creating (what seems to be) an extra variable and why put an underscore before a new variable with the same name as the last. I have read that it is to do with creating instance variables but why would you want to create a UI element as an instance variable? Can you please provide a use case? This objective c code for use in iOS development. Thanks. 回答1: When you @synthesize a property and you do not provide your own getter and setter methods (in

What is the difference between local, instance, and class variables? [duplicate]

醉酒当歌 提交于 2019-12-23 02:07:22
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Difference between class variables and class instance variables? While reading a Ruby book, I seem to have missed the variables chapter. Now I can't seem to understand the following things: What is an instance variable? What is a class instance variable? What is the difference between a variable , @instance_var and @class_instance_var ? I tried to read some posts in different blogs, but I still do not understand