Questions tagged [instance]

In object-oriented programming an instance is an occurrence or a copy of an object, whether currently executing or not.

Instances of a class share the same set of attributes, yet will typically differ in what those attributes contain. For example, a class "Employee" would describe the attributes common to all instances of the Employee class. For the purposes of the task being solved Employee objects may be generally alike, but vary in such attributes as "name" and "salary".

Related tags:

5388 questions
1
vote
3 answers

Trying to add a node to a graph

I am implementing a Graph via adjacency list, and I am trying to add a node to a Graph class but I keep getting an error System.NullReferenceException has been thrown this is the bit of my code: MyNode class class node { public…
1
vote
1 answer

Calling an instance method without creating an instance of class in Python

I read on that instance methods can only be called by creating an instance (object) of the class. But it appears that I can call one without doing so. Check the code below: class Test: def func(self): #Instance Method …
1
vote
0 answers

Making Multiple Instances of Spotify-web-api-js

I am making a React App with the Spotify-web-api-js package, which is a wrapper over the Spotify API. It can be instantiated and used like this: let SpotifyWebApi = require('spotify-web-api-js'); let spotifyApi = new…
Parsa
  • 23
  • 2
1
vote
1 answer

google sheets - is there a way to "instance" cell formatting?

I have 2 sheets: In Sheet1!A1:A is a list of values, the cells have formatting to color them appropriately. In Sheet2!A1:A is the formula: "={Sheet1!A1:A}" This instances the cell values, but not the formatting. Is there a way to get the formatting…
1
vote
1 answer

google sheets - formula to create an "instance" of a column? similar to SORT but without sorting?

I have a simple column with a list of values, that can be of variable length. I want to have a "live" instance of that column in another sheet. I have succeeded with using the obvious formula like this on the target…
Cam
  • 35
  • 3
1
vote
1 answer

Creating multiples instances in Google App Engine JAVA

I am testing Google App Engine using JAVA and I want to test to run multiples instances in parallel. However, I don't know how to activate multiples instances. I tried running this Servlet in different browser (also I tried running concurrent calls…
magallanes
  • 6,583
  • 4
  • 54
  • 55
1
vote
0 answers

Python mock.patch class instance attribute

Is it possible to patch an instance attribute of a class with only a path string and not directly by importing the class and using mock.patch.object Example: file.py class A: def __init__(self): self.a = 1 test_file.py instead of import…
gustavz
  • 2,964
  • 3
  • 25
  • 47
1
vote
2 answers

Check if instance of python class has attribute without instantiating the class

Is it possible to check if an instance of a class has an attribute without (being able to) instantiating the class? Example: class A where I lack knowledge about arguments to instantiate: class A: def __init__(self, unkown): self.a =…
gustavz
  • 2,964
  • 3
  • 25
  • 47
1
vote
1 answer

How to create a class just after starting Django server and access its members later in views.py

I encountered a simple issue in Django, there were similar questions on this forum but haven't answered correctly so i'm writing it again. My issue is just same as this question. How to instantiate a class just after starting Django server and…
Oh Wan Sik
  • 75
  • 1
  • 9
1
vote
2 answers

Is it suspicious to think that methods go missing in ruby?

class Person def name puts "Doharey" end end puts Person.class #=> this out puts Class puts Class.methods.count #=> 82 methods puts Person.methods.count #=> 82 methods In the above example a Person class is created which inherits from…
pankajdoharey
  • 1,562
  • 19
  • 30
1
vote
4 answers

A class that only allows me to fill instances of the first type created

This is what it does: The content of the first instance of the class ( in this case mok1 ) gets filled with water. I can fill it infinitely but as soon as the first instance is created, I can only fill that instance and generate a error by any other…
Jim Clermonts
  • 1,694
  • 8
  • 39
  • 94
1
vote
1 answer

How to get the active instance template name in a managed instance group

I am trying to get the instance template name of an instance group. In the GCP console, the instance template is included in the display (see sample screenshot). However, i cannot find a gcloud command that will give this info, for example: gcloud…
slabsken
  • 35
  • 2
1
vote
2 answers

Creating and storing objects in a container without using new?

Say I have the class class A{ int value; public: A(int val) : value(val) {}; } I store pointers of instances in a collection such as vector using for loop std::vector myCollection; for (int i = 0; i < 10; ++i){ …
Jamie
  • 31
  • 1
  • 3
1
vote
1 answer

Azure SQL MI - advantages of using a private endpoint

Seems like an easy question but since SQL MI already requires a subnet delegated to it, Why Would you use a private endpoint? You already have a private IP address which will keep traffic contained to the Azure backbone? In my case we have a DB used…
mac
  • 307
  • 2
  • 17
1
vote
0 answers

Binary tree not clearing with each loop iteration

I am using a binary tree to convert prefix expression into infix, and then solving them. That part works fully. My issue is the input loop I set up is adding on the new expression to the old tree, resulting in an error. I have tried clearing the…
beatmaister
  • 375
  • 1
  • 14