instance

Method accessing protected property of another object of the same class

假如想象 提交于 2019-12-07 00:01:09
问题 Should an object's method be able to access a protected property of another object of the same class? I'm coding in PHP, and I just discovered that an object's protected property is allowed to be accessed by a method of the same class even if not of the same object. In the example, at first, you'll get "3" in the output - as function readOtherUser will have successfully accessed the value -, and after that a PHP fatal error will occur - as the main program will have failed accessing the same

Find where a class was instantiated

放肆的年华 提交于 2019-12-06 22:51:39
I have trying to solve the error : Fatal error: Cannot redeclare class I have been looking everywhere and I can't find where the class was instantiated. Is there anyway I can print debug info about the existing instance of that class. Chances are you are importing the file that declares the class more than once. This can be symptomatic of includes/requires getting out of control so you may need to simply your structure. One alternative approach is to use autoload to load classes to avoid this kind of problem. Another is to only use include_once or require_once. I generally prefer to use

How to automatically maintain a list of class instances?

感情迁移 提交于 2019-12-06 14:21:39
In my C++ project, I have an Engine class and an Object class. My issue lies with how my instances of Object are created. Currently this is done through the use of a CreateObject(parameters) function in the Engine class. This adds a new instance of Object to an std::vector of Object instances. I want to maintain this list of instances of Object in my Engine class, but without the need for the CreateObject(parameters) function. My reason for this is so that I can create new classes that can inherit from Object but still be added to this list. The reason for this list is so that (in Engine ) I

VBA change instance variable from module (excel)

一世执手 提交于 2019-12-06 14:13:46
In VBA I need a module sub to tell an instance to set up some variables. In Module 1 I have: Sub Load() ThisWorkbook.SetupVariables ThisWorkbook.TestVariables End Sub In ThisWorkbook I have: Private Variable1 As Integer Private Variable2 As String Private Variable3 As MyUserDefinedObjectType Public Sub SetupVariables() Variable1 = 5 Variable2 = "Five" Set Variable3 = New MyUserDefinedObjectType() End Sub Sub TestVariables() MsgBox Variable1 & " is spelled " & Variable2 Variable3.SomeFunction End Sub The call to TestVariables inside Load() yields the correct result, but subsequent calls to

Oracle中数据库实例、表空间、用户、模式的概念及关系

最后都变了- 提交于 2019-12-06 13:04:19
数据库 实例 :    用Oracle官方描述:实例是访问Oracle数据库所需的一部分计算机内存和辅助处理后台进程,是由进程和这些进程所使用的内存(SGA)所构成一个集合。 我们访问Oracle都是访问一个实例,但这个实例如果关联了数据库文件,就是可以访问的,如果没有,就会得到实例不可用的错误。 实例名指的是用于响应某个数据库操作的数据库管理系统的名称。她同时也叫SID。实例名是由参数instance_name决定的。查询当前数据库实例名: select instance_name from v$instance;   数据库实例名(instance_name)用于对外部连接。在操作系统中要取得与数据库的联系,必须使用数据库实例名。比如我们做开发,要连接数据库,就得连接数据库实例名: jdbc:oracle:thin: @localhost :1521:orcl(orcl就为数据库实例名)   一个数据库可以有多个实例,在作数据库服务集群的时候可以用到。 数据文件 :(待续) 表空间: 一个数据库由多个表空间组成,一个表空间只能属于一个数据库。 一个表空间可以包含一个或多个数据文件, 一个数据文件只能属于一个表空间 。    Oracle数据库是通过表空间来存储物理表的,一个数据库实例可以有N个表空间,一个表空间下可以有N张表。有了数据库,就可以创建表空间。   创建表空间语法:

Instance of an interface without an implementation class

非 Y 不嫁゛ 提交于 2019-12-06 12:58:23
问题 I have a JET Template that is meant to generate code for an interface implementation class. I am having trouble coming up with an executable test class that prints out this generated code because I am unable to get an object for the argument of the generate method created from the JET Template. I want the test class to work something like this: /** * An executable test class that prints out exemplary generator output * and demonstrates that the JET template does what it should. */ public

Sharing instance variables between classes ruby

拥有回忆 提交于 2019-12-06 12:03:06
问题 I know that this question has been answered before, but I can't seem to make any of the solutions work I'm making a ruby wrapper for an API that I need to call. The Interface class does all of the session handling and actual calling of the api, but I want to build helper classes for the functions that I will be performing most frequently. The problem I am having is that I need a way of maintaining one instance of the Interface class across multiple helper classes. Here's the code I have so

Accessing the same instance of a class in another form

拜拜、爱过 提交于 2019-12-06 11:59:27
问题 I'm sure this is a simple question, but I don't have enough experience to know the answer. :) DataClass, Form1, Form2 I have a public class, DataClass , in a separate file, DataClass.vb . In DataClass I have data stored in several arrays that I need to access. I have methods in DataClass so that I can access the data. One of them is GetName . Everything works fine on Form1 . I need to access the same data in the arrays on a another form, but I am required to call a new instance of the class,

Django prepopulate form with the fields from the database

◇◆丶佛笑我妖孽 提交于 2019-12-06 11:08:19
i have a privacy form, in wich i am selecting what application should be hidden when one accesses a user's profile. The form contains several checkboxes,and the user checks what he wants to be hidden. What i want is, when a user accesses this form, the form to be an instance of the privacy form already saved, if it exists one. I mean, if i already checked hide application 1, when i am accessing the form again, the corresponding check box to be checked. my code: def save_privacy(request): if request.method == 'POST': try: u = Privacy.objects.get(user_privacy = request.user) form = PrivacyForm

Matlab class with knowledge of instance name in the constructor

。_饼干妹妹 提交于 2019-12-06 10:46:46
I would like to have a class which, in its constructor, can have knowledge (extract as a string) its instance name. For the moment I worked the name extraction out like this: classdef mysession methods (Access = public) function this=mysession (varargin) this.cargs=varargin; this.built=false; end function id=build(this) id=this.mynameis; this.id = id; %% instructions needing id built=true; end function name = mynameis (this) name=evalin ('caller', 'inputname'); end end properties (Access=private) id built cargs end end which requires the ugly A = mysession; A.build syntax in order to work...