Questions tagged [instantiation]

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.

2609 questions
0
votes
2 answers

How to create a new instance from within abstract class in an instance method?

I would like to be able to create a new instance of a class when it's in a variable whose type is abstract. class Scratch { public static void main(String[] args) { Implementation implementation = new Implementation(); //…
0
votes
2 answers

Re-instantiate Class variable in Dart / Flutter

At the beginning of my app I have a global variable gameData which is declared and instantiated as: GameData gameData = GameData(); Later I want to clear the gameData variable and re-instantiate/reset the variable with a clean instance of GameData.…
stfn3000
  • 193
  • 1
  • 1
  • 8
0
votes
3 answers

implicit template method instantion

I have a class containing a template method with a non-type template parameter. The code size got really big, so I tried avoiding the inlining by putting it into the .cpp file. But I can only manage to instantiate it explictly for each non-type…
Mirco
  • 107
  • 2
  • 11
0
votes
1 answer

I am forced to do a null pointer exception for my node

My code is meant to take in a bunch of variables from a GUI and have them inserted into a linked list of nodes to be called when all the information is to be printed. My declaration looks like this (Just incase this information is needed). public…
0
votes
0 answers

How to invoke a method using reflection in JavaScript

When I require information from my server I send a packet via a Worker, specifying inside the packet the name of the function to be called when it is returned. The worker sends the packet to the server via a websocket. I use websockets because…
Richard
  • 11
  • 5
0
votes
1 answer

Unity UI scaling and instanced prefabs

I'm trying to set up UI elements that are instantiated from prefabs. I use SetParent to put them under a UI elements that's directly under the Canvas. The issue is that when the UI scales, these prefabbed elements don't stick to the part of the…
0
votes
1 answer

Does resampling have to be instantiated in mlr3?

It was said that resampling object should be instantiated before training in mlr3 book. But sometimes it was not and can be trained and predicted successfully. I want to know when it should be instantiated with $instantiate(task) slot.
0
votes
1 answer

How to properly initialize a variable in python

I tried searching this up before asking it here, but from what I have searched it does not seem to be asked in the form that I am thinking. For a simple example, imagine a situation where I have a list of integers [1, 2, 3, 4, 5] and I want to…
Mitchnoff
  • 495
  • 2
  • 7
0
votes
1 answer

How can I instantiate a prefab to the side of object you collide with?

I am trying to have my player land on a tile and if it lands on that tile place a new tile to the side of the tile you land on. Currently how I have it, it will place the new tile on the first starting one.I added a photo to help make sense of what…
Chris
  • 59
  • 1
  • 3
0
votes
1 answer

class(with static member) initialization in c++

I was trying to understand friend functions and I found myself writing the following code though I have understood the friend functions, this code leaves me with new questions: how does the class initialise here when I havn't instantiaied any…
rosxnb
  • 11
  • 4
0
votes
1 answer

Why this class have to be case class?

This class: class Id[A](value: A) { def map[B](f: A => B): Id[B] = Id(f(value)) def flatMap[B](f: A => Id[B]): Id[B] = f(value) } got error:"not found value Id" at line 2 it's fine if the class is a case class: case class Id[A](value: A) { I…
wang kai
  • 1,673
  • 3
  • 12
  • 21
0
votes
1 answer

Why my unity editor crash? with using Instantiate

I ran this code. And unity stopped. And unity gets closed after 1 to 10 min When I remove Instantiate this code works very well! How can I make this code run great? Unity Editor.log file :…
Oein
  • 15
  • 7
0
votes
2 answers

Why do I need parentheses when instantiating a class?

class Human: def exist(self) return print("exists") H1 = Human # Why do I need parentheses here? I get error if i dont put parentheses here. H1.exist() # I get an error that says parameter 'self' unfilled. Class Human does not take…
0
votes
1 answer

Spawn multiple cubes with Array data

I want help with this problem of mine. Let's consider I want to spawn a Rubik cube (3 3 3). And I want the spawning to happen in this way where we pass 4 data to the game / every cube has 4 data like x,y,z,t where x,y,z are location coordinates & t…
IcyThug
  • 78
  • 1
  • 9
0
votes
2 answers

How to instantiate an object to the where the camera is looking at in Unity

I have been making a first person game called "shoot the ball into the bin". The camera is in a cylinder as a player also the cylinder has collision. I have been struggling with the main driver of the game. Like in most first person shooter games,…