Instantiation is the process of creating objects from a class in most object oriented and object based languages. In the C++ language, instantiation is the process of creating a class or function from a class template or function template.
Questions tagged [instantiation]
2609 questions
0
votes
1 answer
ActionScript 3 Singleton instantiation - advice
I have an AS3 Singleton:
package
{
public class Singleton
{
public function Singleton(enforcer:SingletonEnforcer):void
{
if(!enforcer){throw new Error("Only one instance of Singleton Class…

Francisc
- 77,430
- 63
- 180
- 276
0
votes
1 answer
OOP throw two dice this.setSumTotal(); does not work
Just been experimenting with a class in which 2 dice are thrown and the total calculated. I am using OOP setting the total to this.dice1+this.dice2. However, when instantiating a Dice in another class the dice1 & dice2 throw work fine and generate 2…

Cameron Grant
- 3
- 1
0
votes
0 answers
When instantiating a class, are there rules for not using the same name for the instantiated object as for the class itself?
Suppose I have a class in a module:
class c():
some_var = "abc"
def f(self):
print("ok")
In a script, I am importing this class and using it as follows:
from my_module import c
c = c()
c.f() # will print "ok"
print(c.some_var) #…

Wannes
- 41
- 5
0
votes
2 answers
C++: Create instance of templated class based on enum values
(How) is it possible to write a function that instantiates a template class based on input values? For example, given the template class:
template
class Container {
T value;
};
I would need a function like
Container> convert(void*…

Green绿色
- 1,620
- 1
- 16
- 43
0
votes
1 answer
Python class attribute 'is not defined' when referenced by another class attribute
Using the following, I am able to successfully create a parser and add my arguments to self._parser through the __init()__ method.
class Parser:
_parser_params = {
'description': 'Generate a version number from the version configuration…

David Gard
- 11,225
- 36
- 115
- 227
0
votes
0 answers
Instanciate new Component in Vue 3 with Data
I program a little chess-like game with Vue
I am trying to instanciate new Pieces with data.
Basicly I want do this (expressed in a different Language):
array.add(new Piece(data))
currently I'm doing this:
const piece = {
name: 'piece',
…

günnni
- 43
- 3
0
votes
3 answers
C++ Not able to instantiate a Template Class
Let me put it step by step. The problem is I am not able to instantiate a Template class. Pls help where am i doing wrong.
I have a template class as below :
template
class HashNodeDefaultPrint {
public:
void…

Abhishek Sagar
- 1,189
- 4
- 20
- 44
0
votes
1 answer
updating instance variable via appending in a function... not working?
I am going to try and add all relevant code here first and then explain my issue. More of a newbie in python for sure, just wanted to do a project that I felt would be challenging to me so I am trying to do something that is a bit like 'And Then…

Will2M
- 1
0
votes
1 answer
Dynamically add property to class in order to return a new object in each call
I have a class Car:
class Car:
def __init__(self, speed):
self.speed = speed
I also have a dictionary cars containing names and speeds of some cars:
cars = {"bmw" : 250, "ferrari": 350, ...}
Now I want to have a container class, which…

Qunatized
- 197
- 1
- 9
0
votes
3 answers
Instantiate a class with a list
I have a class called Player...
class Player:
def __init__(self,name,score=6):
self.name=name
self.score=score
self.roll = 0
...And I have a class called Game
class Game:
def __init__(self,players):
…

ill13
- 29
- 4
0
votes
2 answers
Processing - Array index out of bounds error
I'm trying to use an array of objects to have barrels fall from the top of the screen to the bottom. (Like that old donkey kong game.) However, I can't seem to find a way to create more instances of the object than whatever the initial length of the…

Brosef3053
- 59
- 5
0
votes
1 answer
Script wont delete instantiate in unity
i have a script that creates a clone over time and delete it but it will only spawn it
public GameObject Obstycle;
public Transform NextSpawn;
public float MaxTimer = 3;
public float Timer = 0;
public void Update()
{
if(Timer > MaxTimer)
…

Fieriko
- 1
0
votes
1 answer
A* (Astar) Pathfinding doesn't work with Player Clone / Instantiate Unity
My player spawns at game play.
when i put my Player Prefab into "target" then it doesn't follow.
but when i put my clone(instance) of my prefab (what spawned in the hierachy when i start the game) into "target" then it works.
how can i do that the…

Felaix
- 5
- 3
0
votes
1 answer
Checking collision with Polygon Collider using Ray cast and instantiating objects issue (unity)
I'm trying to check collision with Polygon collider using Raycast on my field in my Unity game. And then create crop on position of ray cast if conditions met by clicking button. Even though it checks collision perfectly i have a few issues that i…

Oleksii Stetsenko
- 13
- 3
0
votes
0 answers
Is this a more optimized alternative to instantiate?
I'm trying to make a custom object pooling class (this is my first time trying to avoid using Instantiate().
I know object pooling is objectively better than instantiating but I'm worried that the way I set it up might actually be worse than…

John
- 197
- 1
- 17