instantiation

How to write to two output ports from inside architecture in VHDL?

∥☆過路亽.° 提交于 2019-12-13 04:25:41
问题 I encountered a problem when trying to connect a component to two output ports of parent hierarchy in VHDL. Since the physical connection can be done only via "port map" statement, there is no way to connect local signal to more than one output port. Here is an example: The description of the above circuit should be smth. like this: entity HIER is port ( IN1 : in bit; OUT1, OUT2 : out bit); end hier; architecture HIER_IMPL of HIER is component BUF is port (a : in bit; o : out bit); end

Create a List of <T> from a base class

跟風遠走 提交于 2019-12-13 03:55:29
问题 I have a base class called SCO that a number of classes inherit from. I initially just wanted to sort the collection, but based off of some recommendations, it sounds like I can instantiate and sort the collection in one method. I have this constructor that all base classes inherit: public SCO(SPListItem item, List<Vote> votes) { UpVotes = voteMeta.UpVotes; DownVotes = voteMeta.DownVotes; VoteTotal = UpVotes - DownVotes; HotScore = Calculation.HotScore(Convert.ToInt32(UpVotes), Convert

Real objects and MVC

穿精又带淫゛_ 提交于 2019-12-13 03:18:53
问题 Until there, I always coded object this way : // initialization $husband = new User('Bob'); $wife = new User('Sarah'); // action $husband->dance(); $wife->read(); // get echo "The husband is ".$husband->getAge()." years old"; But with CodeIgniter (and MVC), it seems it's better to think this way : // load model $this->load->model('user'); // action $this->user->dance('Bob'); $this->user->read('Sarah'); // get echo $this->user->getAge('Bob'); But in this case, how to deal with "real objects" ?

Having a difficult time making a static method which utilizes non-static methods

那年仲夏 提交于 2019-12-13 03:17:05
问题 I'm about 6 weeks into learning Java and still struggling with implementing static methods (thought I really understood it, but this proved me wrong!). I'm trying to make the value of a locally stored key-value pair available publicly. Here's my initial code: public class Settings extends Activity implements OnClickListener { public Settings(TextView loginText, TextView passwdText) { super(); this.loginText = loginText; this.passwdText = passwdText; } public static String getDriverNum() {

Value assigned is not used in any execution path - C# [duplicate]

末鹿安然 提交于 2019-12-13 00:47:46
问题 This question already has answers here : C# Is this initialiser really redundant? (6 answers) Closed 4 years ago . Resharper is showing this warning: "value assigned is not used in any execution path" when I write the following code: List<obj> testObj = new List<obj>(); testObj = testMethod(); Here testMethod() returns type List<obj> . However when I directly assign the testMethod() without instantiating it, I don't get the warning. List<obj> testObj = testMethod(); Forgive me for my

Object initializer syntax (c#) in python?

孤人 提交于 2019-12-12 16:00:11
问题 I was wondering if there is a quick way to initialise an object in python. For example in c# you can instantiate an object and set the fields/properties like... SomeClass myObject = new SomeClass() { variableX = "value", variableY = 120 }; Thanks Brian 回答1: If you want a quick dirty object with some fields, I highly suggest using namedtuples from collections import namedtuple SomeClass = namedtuple('Name of class', ['variableX', 'variableY'], verbose=True) myObject = SomeClass("value", 120)

If I do not want to instantiate a class, what are my options?

痴心易碎 提交于 2019-12-12 15:53:25
问题 I have a class with all static methods which basically makes calls like ClassName#MethodName() . I want this class to be non-instantiable at all times and so I have set the constructor visibility to be private . This certainly avoids any instance of it being created from outside the class. I want to know if there is any technical term coined or any design pattern specifically designed for doing exactly this which I do not know of. Also this does not stop me or any other developer from

How to instantiate generics using wild card?

孤街浪徒 提交于 2019-12-12 14:36:36
问题 Lets research some generic instantion situation using wild card: 1 This code List<?> list = new ArrayList<?>(); generates following error: required: class or interface without bounds found: ? 2 But this List<?> list = new ArrayList< Set<?> >(); compiles succesfully. 3 and this: List<Set<?>> list = new ArrayList< Set<?> >(); compiles succesfully too. 4 but this: List<Set<Map<?,?>>> list = new ArrayList< Set<Map<String,String>> >(); generates required: List<Set<Map<?,?>>> found: ArrayList<Set

Instantiating objects when using Spring, for testing vs production

孤街醉人 提交于 2019-12-12 09:39:15
问题 Am correct in understanding that when using Spring, you should use the Spring configuration xml to instantiate your objects for production, and directly instantiate objects when testing? Eg. MyMain.java package org.world.hello; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MyMain { private Room room; public static void speak(String str) { System.out.println(str); } public static void main(String[]

How to instantiate a static vector of object?

此生再无相见时 提交于 2019-12-12 08:29:50
问题 I have a class A, which has a static vector of objects. The objects are of class B class A { public: static void InstantiateVector(); private: static vector<B> vector_of_B; } In function InstantiateVector() for (i=0; i < 5; i++) { B b = B(); vector<B>.push_back(b); } But I have compilation error using visual studio 2008: unresolved external symbol... Is it possible to instantiate static vector using above method? For object b to be created, some data has to be read from input file, and stored