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
2 answers

Class Instances and ambiguous occurence in Haskell

Here is the code: data Tree t = NilT | Node t (Tree t) (Tree t) instance Show (Tree t) where show NilT = "" show Node t l r = (show t) ++ ", " ++ (show l) ++ ", " ++ (show r) how to use "show" in "t show" with the default setting…
1
vote
1 answer

How to retrieve an attribute from a list of instances properly

I am unsure how to correctly get the attribute from a list of instances. Sorry if this seems simple, I am only a beginner. class Clown: def __init__(self,name,hours,job): self.name = name self.hours = hours self.job =…
Tariq
  • 30
  • 4
1
vote
1 answer

if con.createStatement() method is present in connection interface then how it is returning statement type refrence

stmt=con.createStatement(); kindly explain this and how we are creating instance of interfaces kindly explain me the instance of interfaces are not possible, but how it is done then
Salman
  • 11
  • 3
1
vote
2 answers

How do I make a constructor take unlimited arguments in c++?

I am reimplementing std::list for educational purposes. I was wondering if there was a way to allow the user to use this syntax for initialization: my::list l = {1, 2, 3, 4, 5};
ugo_capeto
  • 129
  • 8
1
vote
2 answers

XNA Difference between List and List[] when you try to create them

So, I have a list of vectors, when I put a new vector in it it works perfectly, but If I try to access an index of List of Vectors and put a vector in it, I get this error "Object reference not set to an instance of an object." The code is almost…
Nairda
  • 119
  • 1
  • 7
1
vote
1 answer

Dynamically call staticmethod in Python

I have a python object that has various attrs, one of them is check=None. class MenuItem: check: bool = True During the __init__() process, it parses it's own attrs and looks if they are callable. If so, it calls the function, and replaces it's…
nerdoc
  • 1,044
  • 10
  • 28
1
vote
1 answer

how to work java instance type in mismatch return type(ex, Object) and reference type(ex, MountBike)?

public class Bicycle { // the Bicycle class has three fields public int cadence; public int gear; public int speed; // the Bicycle class has one constructor public Bicycle(int startCadence, int startSpeed, int startGear) { …
Hooni
  • 13
  • 2
1
vote
3 answers

Python: difference class with __init__ and class without it

I'm learning how classes works and I got stuck on a thing which I can't explain, I also didn't find a solution on the Internet so here am I with my first question on StackOverflow. class Swords: damage = 5 Here is a class with only one line,…
Acid Fronn
  • 13
  • 3
1
vote
1 answer

How do I assign unique instances as multiple keys to a dictionary in R?

I have an R df where one column, assignment, looks like this: course instance assignment 1 1 A 1 1 B 1 2 B 1 2 C 2 1 A 2 1 C 2 2 B 2 2 A I need to create a superset (for lack of a better term) of all of the assignments in a…
bvecc
  • 187
  • 4
  • 14
1
vote
2 answers

Injecting floor database dependency through GETX is not working : Flutter

I am new at using Getx for state management. I am trying to inject the dependency of my DB instance in main by Getx through initial binding I am using the floor database. can anyone help me with this. where I went wrong? this is how my register…
1
vote
4 answers

haskell -- can one access type variables from an instance function declaration?

I want to access type variables in an instance, that don't show up in the instance's parameters. For example, class A a where foo :: a b data C a instance A C where foo :: forall b. C b foo = undefined :: C b Of course, the above will…
gatoatigrado
  • 16,580
  • 18
  • 81
  • 143
1
vote
0 answers

How to print instance address in swift?

I want to print instance address. But I use protocol to create Person. And I get error like Generic struct 'Unmanaged' requires that 'Person' be a class type Have any idea to print parent instance address? protocol Person { var name: String {…
Beginnerrrrrr
  • 537
  • 1
  • 8
  • 27
1
vote
1 answer

Overriding class function with instance function in python

Consider this example: class master: @classmethod def foo(cls): cls.bar() class slaveClass( master ): @classmethod def bar(cls): print("This is class method") slaveType = slaveClass slaveType.foo() class…
Johu
  • 626
  • 7
  • 15
1
vote
1 answer

Selenium webdriver - How to connect to the same firefox instance open by Visual Studio using C#

Hello friends. I would like some help. I've been trying to use the same instance of Firefox window open by Visual Studio at first time. The question is, how to pickup the same window browser and continue to testing without it close the browser and…
R4wd0G
  • 41
  • 1
  • 1
  • 6
1
vote
1 answer

Saving and loading instances of an object in Unity

I'm trying to make a program in Unity that consists of a user interface where I can create teams with several stats (health, mana, and exp), and manage the stats for each team. The team management itself seems to be working, but I'm struggling to…
Nowko
  • 11
  • 1