instantiation

Instantiate an object without calling its constructor in PHP

我们两清 提交于 2019-12-08 14:38:14
问题 To restore the state of an object which has been persisted, I'd like to create an empty instance of the class, without calling its constructor, to later set the properties with Reflection. The only way I found, which is the way Doctrine does, is to create a fake serialization of the object, and to unserialize() it: function prototype($class) { $serialized = sprintf('O:%u:"%s":0:{}', strlen($class), $class); return unserialize($serialized); } Is there another, less hacky way, to do that? I was

How to pass a list of unknown objects of type custom-class containing some properties to method?

梦想的初衷 提交于 2019-12-08 05:22:42
问题 I am making a databasehelper class with methods to access a SQLCE database. I want to use the same method to read row(s) using different classes containing properties that match the fields in the different tables. The class to be used is determined during runtime and I want to pass a list with objects from the class on to the method and get the propertynames and use them to read the database. Would be very handy because I could use it for all my (SQLCE-)databases. (I updated the erroneous

Problem about instantiating Java chaincode in Hyperledger Fabric v1.3 - Failed to invoke chaincode name:“lscc”

。_饼干妹妹 提交于 2019-12-08 04:30:07
问题 I have a problem while instantiating the Chaincode in Hyperledger Fabric v1.3. In the tutorial 'Building your first network' on the official website of Hyperledger Fabric, the java chaincode was successfully instantiated without any problems. However, When I created a chaincode that I made myself, the following lscc error is occurring: Screenshot of exception stack trace Screenshot of error message 回答1: Reproduced the same problem v1.3 Java SDK + Java Chaincode instantiation :) several times,

an enclosing instance that contains X.Y.Z is required

蓝咒 提交于 2019-12-08 03:51:22
问题 I'm hoping someone can help me out. I've been researching this problem for hours and nobody else seems to have had the same issue (that I've come across). I must be making some really bonehead mistake. I'm new to Java and have designed a very simple Java program. I have an abstract superclass called Student. This Student superclass has 3 extending classes called Graduate , Undergraduate , and PartTime . The Student class has several abstract methods and several non-abstract methods. I've

Using DirectShow filters outside DirectShow?

懵懂的女人 提交于 2019-12-08 03:31:05
问题 I'm currently dealing with Windows Media Foundation. However, due to some problems with the Microsoft H.264 decoder and some missing decoders for custom format, I'd like to know if it would be possible to instantiate a DirectShow Decoder directly using CLSID, and build a proxy around it that exposes IMFTransform to get a decoder for Media Foundation. So here is my question: Can i instantiate a Directshow filter (preferrably decoders) directly and use them for decoding (i.e. put some

gcc problem with explicit template instantiation?

戏子无情 提交于 2019-12-08 03:22:34
问题 It is my understanding that either a declaration or typedef of a specialization ought to cause a template class to be instantiated, but this does not appear to be happening with gcc. E.g. I have a template class, template class Foo {}; I write class Foo<double>; or typedef Foo<double> DoubleFoo; but after compilation the symbol table of the resulting object file does not contain the members of Foo. If I create an instance : Foo<double> aFoo; then of course the symbols are all generated. Has

instantiation class before defined

怎甘沉沦 提交于 2019-12-08 03:08:09
问题 in php.net the following is written: Classes should be defined before instantiation (and in some cases this is a requirement). can anyone give an example when it is required? because a typical use of it doesn't require, like in this example that works ok: <?php $class = "a" ; $ob = new $class() ; class a { var $city = "new york" ; } echo $ob->city ; ?> 回答1: This won't work: new Foo; if (true) { class Foo { } } Conditionally declared classes must come first. Basically, anything that's at the

How do I instantiate an instance of a generic method parameter in Java?

杀马特。学长 韩版系。学妹 提交于 2019-12-08 01:32:49
问题 Consider the following code: // ... public class BaseClass { public BaseClass (int theParam) { // ...whatever... } } public class DerivedType { // ...Content does not matter... } // ...elsewhere: public <ElemType extends BaseClass> boolean doIt (ArrayList<ElemType> target) { ElemType newElem=new ElemType (5) ; // "Cannot instantiate this type" // ...other code does not matter... return true ; } // .. How can I create an instance of type ElemType in doIt ? The construct shown yields the error

Why can't I instantiate a generic class inferring types from anonymous objects?

人走茶凉 提交于 2019-12-07 21:55:15
问题 Let's say I have some class - hypothetical example: public class InvalidResponseException<TReq, TResp> : Exception { public TReq RequestData { get; protected set; } public TResp ResponseData { get; protected set; } public InvalidResponseException(string message, TReq requestData, TResp responseData) : this(message, null, requestData, responseData) { } public InvalidResponseException(string message, Exception innerException, TReq requestData, TResp responseData) : base(message, innerException)

Best practice curiosity regarding String instantiation [duplicate]

倖福魔咒の 提交于 2019-12-07 18:04:51
问题 This question already has answers here : Strings are objects in Java, so why don't we use 'new' to create them? (14 answers) Closed 6 years ago . I was reading some advices about best practices in java and I got the following idea which made me curious Also whenever you want to instantiate a String object, never use its constructor but always instantiate it directly. For example: //slow instantiation String slow = new String("Yet another string object"); //fast instantiation String fast =