Questions tagged [objectinstantiation]
92 questions
1
vote
0 answers
Is instantiating an object in Unity3D causing my timer-based script to become unreliable because of performance issues?
First of all, since I've found much great help from other posts I found here, I considered signing up, so this is my first post I suppose!
Regardless, I am currently working on a Unity3D game in C#, where we essentially have an endless driving game…

ZetShock
- 11
- 1
1
vote
1 answer
Get value of object used in genetic algorithm
@staticmethod
def _select_tournament_population(pop):
tournament_pop = Population(0)
i = 0
while i < TOURNAMENT_SELECTION_SIZE:
tournament_pop.get_chromosomes().append(pop.get_chromosomes()[random.randrange(0,…

Bipin Mishra
- 31
- 5
1
vote
3 answers
Create object of parameter type
hey. Is it possible to have a method that allows the user to pass in a parameter of a certain type and have the method instantiate a new object of that type? I would like to do something like this: (I don't know if generics is the way to go, but…

XSL
- 2,965
- 7
- 38
- 61
1
vote
1 answer
What Happens When We Instantiate a PHP Class?
Well, i keep hearing that you better not get use of static methods in php, i can understand that to some extent, But there are some confusions for me, what i want to know is :
Let's say i'm writing an application, i define hundreds of classes ( Or…

Arsi
- 191
- 1
- 1
- 10
1
vote
3 answers
What could possibly cause this error when declaring an object inside a class?
I'm battling with this assignment :)
I've got two classes: Ocean and Grid.
When I declare an object of the Grid inside the Ocean:
unsigned int sharkCount;
Grid grid;
The compiler/complainer says:
error C2146: syntax error : missing ';' before…

m4design
- 2,112
- 3
- 21
- 28
1
vote
3 answers
C++ Instantiating "Implicit" Class Object
class Cents
{
private:
int m_nCents;
public:
Cents(int nCents) { m_nCents = nCents; }
// Overload cCents + int
friend Cents operator+(const Cents &cCents, int nCents);
int GetCents() { return m_nCents; }
};
// note: this function is not a member…

Max Green
- 25
- 5
1
vote
2 answers
Swift - Object instantiation in Test class
I am trying to test a class I have written. I have added a new test target and in there I have imported the target of the class I am trying to test. My code looks like this:
import XCTest
import TargetContainingClass
class Tests: XCTestCase
{
…

gcjensen
- 11
- 2
1
vote
2 answers
How do I create a development tool to create custom object instances for iphone os
I'm setting out to create an app where it will use 7-10 instances of a custom class, lets call them "books" each class will consist of a number of pages, a title, a int of how many pages a book contains and possibly some notes of the author…

nickthedude
- 4,925
- 10
- 36
- 51
1
vote
3 answers
Diferences between object instantiation in C#: storing objects in references vs. calling a method directly
I have a doubt with the objects declarations in c#. I explain with this example
I can do this:
MyObject obj = New MyObject();
int a = obj.getInt();
Or I can do this
int a = new MyObject().getInt();
The result are the same, but, exists any…

amelian
- 436
- 1
- 6
- 17
1
vote
1 answer
Test assert fail: Null reference exception. Object Reference not set to an Instance of an object
Ok so I have one line of code that is causing me grief, but unfortunately without it, my program breaks. It is the only way I can think of (aside from completely restructuring my program) to do what I want it to do.
The purpose of this line is to…

Ben
- 2,433
- 5
- 39
- 69
1
vote
2 answers
Instantiating a class with no default constructor
For many framework development, we need to instantiate class by reading qualified class names from a config file.
There are different introspection strategies, and dedicated libraries (like Objenesis) geared towards it.
However, for classes with no…

sutanu dalui
- 663
- 7
- 25
1
vote
1 answer
Scala, Casbah: Compilation errors. How to instatiate object from external libary?
I am trying to write function that writes data to MongoDB using Casbah toolkit:
import com.mongodb.casbah.WriteConcern
import ...
def saveRecord(rec: MongoDBObject) {
mongoColl.insert(rec, WriteConcern)
}
Casbah defines…

Anton Ashanin
- 1,817
- 5
- 30
- 43
1
vote
2 answers
Instantiating List with generic type possible?
A student that I am tutoring is taking a web development class that uses a Dietel book on Java, which contains this curious bit of code involving Generics:
class StackComposition
{
private List stackList;
public StackComposition()
…

dtg
- 1,803
- 4
- 30
- 44
0
votes
2 answers
declaration/definition and instantiation of COM objects with visual c++?
i need to instantiate com object which is .dll and on local machine in visual c++,i know that it can be done by using CoCreateInstance("clsid") ,but i am confused about declaration.so can anyone explain all steps involved?
for late binding as well…

user1176743
- 5
- 1
- 4
0
votes
0 answers
Can't get namespaced PHP class to load using string type variable, yet just naming the instance the same thing works?
So I have a file lookup.php that's using spl_autoload_register() at the top. It's also namedspaced as "App\Http\Controllers\StaticObjects"
Within the file I have a method that's used to load in classes dynamically based on an array.
foreach…

Mike Reed
- 74
- 7