Skip to main content

All Questions

Tagged with
0 votes
0 answers
34 views

Initializing Array size to the size that is initialized in constructor throws ArrayIndexOutOfBoundsException [duplicate]

I'm trying to create a Shelter Class, where i can shelter Animals(which is another class that has two extensions Catg,Dog) but when i initalize the shelter's size with a constructor and then ...
hasansabbath71's user avatar
0 votes
3 answers
36 views

Primitives class variables of metaclass not shared between subclasses in python, but objects are, why?

consider these two pieces of code: class M(type): hey = [] class S(metaclass=M): pass class N(metaclass=M): pass print(S.hey) # output [] print(N.hey) # output [] S.hey.append(6) ...
Amir Kooshky's user avatar
-3 votes
1 answer
60 views

Why does the below python code not throw error? [closed]

How does line 3 even get executed even though the function two() is defined below one() which makes it out of scope?! def one(): temp = "I am Aditya" return two def two(temp): ...
Aditya Mutharia's user avatar
0 votes
0 answers
29 views

How can i make all variables outiside accessible inside a method in PHP

I undestand that would be considered a bad practice but my purpose is just for study, i wanna undestand if a function "render" with a include inside, can have this include to have access to ...
Vinicius Cavalcante Santos's user avatar
0 votes
1 answer
354 views

setInterval returns undefined OR scope of returned value wrong [duplicate]

I try to store Date.now() after a setIntervall invoked a callback. After that, I'd like to clear the intervall, so it only fires once. All that in a class. But the variable I store the intervalID in ...
Manticor's user avatar
0 votes
1 answer
29 views

C++, conflicting between library function and inhertited class function [duplicate]

#include <iostream> #include <unistd.h> using namespace std; class A{ public: bool close(){ return true; } }; class B: public A{ public: void fun(){ (...
R_S's user avatar
  • 11
0 votes
2 answers
96 views

How to scope internal functions within a MAIN function?

My young son and I were playing a board game called Snails Pace. Simple enough, so I sat down to show him the game on the R-console. Helper function num.round = function(n, by=5) { byidx = (n ...
mshaffer's user avatar
  • 973
1 vote
1 answer
61 views

Would scope would this variable(s) belong to?

class Something: x = "hi" def func(self): k = "hi2" In this piece of code, x as a class attribute and k as a variable. What scope (local, enclosed, global, builtin)...
user avatar
0 votes
1 answer
79 views

Using Tkinter and OOP to create transition frames in different classes (Python)

I am creating frames for my project and so far I have it where it goes from the home page to the main page when the button is clicked. The problem I am facing is when I try to go from the home page to ...
user avatar
1 vote
2 answers
189 views

Attempting OOP for Python RPG

I am trying to learn Python OOP and have been struggling to understand scope, passing values and how to encapsulate. My earlier attempts have rapidly become spaghetti code (likely because my only ...
misfit138's user avatar
0 votes
1 answer
64 views

How do I pass a variable from one method to another within the same class in Dart?

I am trying to pass the "l" variable from the purchase method to greet method within the same "Customer" class. How can I do this? I have tried in many ways but couldn't get the ...
Md. Rezuwan Hassan's user avatar
0 votes
0 answers
89 views

variable reassignment issue in java

I have my code behaving the way I'm expecting it to behave except for one last issue. In the while loop within void main() while (gameStatus == Status.CONTINUE) I'm trying to set the variable ...
tedico's user avatar
  • 67
1 vote
1 answer
256 views

How to deal with ctime includes within the scope of a class in CPP?

I want to use <ctime> inside the scope of a class in C++. However, whenever I try to compile the following class, I get the error: error: 'time' cannot be used as a function time_t now = ...
Breno's user avatar
  • 165
0 votes
2 answers
113 views

OOP Question About Vanilla JS: The class's constructor won't accept the variable I'm feeding it as a parameter

I'm trying to learn OOP through practice, but I'm pretty stuck at this point. This is the code: const itemEdit = () => { let editIndex = buttonObj.editArr.indexOf(editID); console.log(`the ...
Auslscher Lysergsure berschrei's user avatar
0 votes
2 answers
191 views

Is there a way for classes to communicate with one another without connecting them through object references?

The hardest problem I'm having is illustrating the problem. It runs, but it feels like there's a much cleaner way to achieve the same thing. Is there a way for a method in one class to communicate ...
Davis Murphy's user avatar

15 30 50 per page
1
2 3 4 5
21