Questions tagged [class]
A template for creating new objects that describes the common state(s) and behavior(s). NOT TO BE CONFUSED WITH HTML CLASSES OR CSS CLASS SELECTORS. Use [html] or [css] instead.
class
79,839 questions
Advice
0
votes
5
replies
57
views
Python class, attribute
I'm struggling with the following code:
...
0
votes
0
answers
55
views
How to show class method comments (docstrings?) from the implementation section in hover hints?
I'd like to document the code I currently have to write as good as poosible.
According to the lazarus documentation:
The Lazarus IDE can display tooltip hints when mouseovering identifiers.
From my ...
4
votes
1
answer
83
views
How to create a class that generates auto-updateable plots
I want to create a class that will create updateable plots. I plan on having 8-16 figures in one window, so it would be nice to have a class that would initiate these for me. These graphs will auto-...
0
votes
1
answer
106
views
How to make a generalized template class? [closed]
I've done some amateur object-oriented programming in C++ and I have a quick question of what is possible when creating your own class.
I've attempted to make a generalized 3-tuple template class that ...
1
vote
1
answer
107
views
Class objects inaccessible for the subs other than the one the object has been instantiated
I run calculations with muliple subs and functions looping up to get a result. Based on the number of iterations done by counters I change some variables to suit my needs. So far the counters have ...
Best practices
0
votes
8
replies
52
views
Initialize a Typescript class property once
Let's say I have a class with many parameters. In Typescript, this is how the class is created:
...
Best practices
0
votes
3
replies
71
views
Python Inheritance Class Argument NameError
I’ve searched the space of Python nested class inheritance and have read that it's not best practice. I have a NameError on the following:
...
Best practices
0
votes
4
replies
224
views
Is it safe to use public functions in C++?
I am creating a program with C++ language that working with strong cryptography.
Does it matter if I use public or private functions where contains a secret algorithms, any sensitive structures of ...
3
votes
1
answer
112
views
Powershell Class generic interface arguments type resolution problem
Can't seems to find why generic interface types are allowed in powershell class argument attributes, but they can't accept anything - powershell class type resolution doesn't work in this case. Is ...
1
vote
2
answers
96
views
JavaScript: How many objects are allocated when returning an object literal from a class constructor?
Let's say I have this code:
class MyClass {
constructor() {
return {};
}
}
const x = new MyClass(); // how many objects are instantiated with this?
...
0
votes
2
answers
121
views
How to break circular dependency in Python class when trying to separate a simple wrapper class from a heavier implementation?
I am trying to build a small scale deep learning framework. I defined my tensor class as follows
...
3
votes
2
answers
113
views
Verbose in class with "using module" directive
I faced a specific behavior while using verbose output in class.
This works like a charm:
...
Advice
1
vote
4
replies
74
views
Add an instance to a virtual subclass?
With abstract subclasses on can use register to add other classes as a "virtual" subclass, what would be a way to do that for a single instance based on it fullfilling some criteria?
The &...
Advice
1
vote
3
replies
65
views
Creating classes/class objects in JS - perhaps jQuery, not sure
What is this?
...
Best practices
0
votes
5
replies
90
views
using variable of type Class<?> in switch construct
i'm in need of a data container for several data types and fail to write some omnipotent :-) converter func.
Maybe my idea is crab, in this case please give me a hint what concept to use.
My current ...
1
vote
2
answers
173
views
Trouble with VBA Class Instantiation [closed]
I've created a VBA Class module and written all the necessary code within it. When I go to use it, in Excel, I instantiate it in a global module as follows.
...
Advice
0
votes
4
replies
128
views
VB.NET and classes and their sub-classes
I have a class in VB.NET. The definition of this class is re-defined according to need.
For example: TR as char(2), F1 as Char(10) then later TS as Char(2) F1 as float.
I want to define one class and ...
2
votes
1
answer
145
views
In python is there a way to get len with int data type and not and index-sized integer? [duplicate]
I working on a code where it is necessary to have large integers, here is a simplified version of it (len_class.py):
...
0
votes
2
answers
148
views
Create a custom method for all existing product types in WooCommerce
I want to create a custom method I can use for any WC_Product class, so I can use $product->get_lead_time(); anytime I have a product object available. I ...
0
votes
1
answer
95
views
2
votes
1
answer
213
views
Void function doesn't print elements of matrix C++
I'm trying to print elements of matrix (example will be below). Here is the following code written in Dev-C++:
...
2
votes
2
answers
130
views
Subtlety in initializing attributes with methods in modules from the `equinox` `jax` library
I have the following code that defines an abstract class and its final subclasse. The two classes are both subclasses of the equinox.Module class, which registers ...
3
votes
4
answers
118
views
Why must classes be defined in order of appearance in python module?
Let's say I have a python file test.py that looks like this:
...
1
vote
3
answers
153
views
Better way to override methods on an instance of a JavaScript class
In our JavaScript web app, we use a custom-made component framework. All of our components are defined as classes using the class syntax.
We can make child classes ...
1
vote
1
answer
85
views
Update a class when the extended super class setter is used
I have an issue with the data within an extension class does not change when I change data within the super class.
This might be an XY issue or caused by the fact that I'm still not used to using <...
-3
votes
1
answer
119
views
How can I pass a reference to an internal class upon construction of a public-facing subclass without violating nullabe safety?
I'm not super experienced with C#, and this is a bit of a puzzle. Consider the following code:
...
0
votes
1
answer
87
views
One object has to work with part of data (line of an array) from another object
I'm not a professional programmer. I'm teaching my children and decided to create a solver to nonograms puzzles. The algorithm itself is not what concerns me, but the proper way to code it.
What I ...
-5
votes
1
answer
147
views
calling a class object in an iterative way on python
I made the next class
...
1
vote
1
answer
160
views
Hide a class method programmatically
A while ago I wrote a small function to easily Use-ClassAccessors in PowerShell. I would like to add a new feature:
Any accessor method (in the form of ...
-4
votes
4
answers
172
views
How to update string attributes to object instances if they exist [closed]
I'm trying to use a for loop to iterate through a set of objects, check if those objects store string data (specifically their 'Pokemon.evolution' variable) which ...
-5
votes
2
answers
106
views
attributes in a class [closed]
I am working on an example of a class called Car. Can you help clarify the difference between the attributes after the initialization statement and those within the ...
0
votes
1
answer
93
views
PHP autoloading with multiple third-party libraries [closed]
I'm writing a plugin that uses a few third-party libraries (one from a long-abandoned repo that I'm modifying). Library A uses Library B, and my code uses both.
In Library A are 50-odd files with ...
0
votes
1
answer
135
views
How to determine class of an element in Javascript
I want to determine the class name of existing table TD elements (using the Chrome Javascript).
My case is table rows all like
...
2
votes
1
answer
111
views
How to separate built-in object from user objects?
I'm trying to write a function TypeNameEx which will return a string which, using a call to VarType(), effectively identifies ...
0
votes
1
answer
260
views
What is the actual implementation of delphi helpers?
type
TTestHelper = class helper for TStringList
procedure Test;
end;
What is the actual implementation of Delphi class helpers? In the ...
2
votes
1
answer
151
views
Unsure how to create relationships between classes within python
The classes works when separate, now, I want to create relationships between them. However, this has caused issues when I am trying to define the relationships.
For example:
...
0
votes
2
answers
264
views
Can the dot operator path be shortened?
In C++ I have variables in classes in classes. It often results in long dot operators to get to the variable. For example:
...
0
votes
2
answers
163
views
How do I make a variable declared in a class in C++
I have a variable, value, declared in a class, input. I want to use it inside main. Here is ...
0
votes
1
answer
67
views
How can I forbid method redefenition in TCL OO class?
I would like that method redefenition would result in failure and script execution stop. Like any other common error.
In the following example I want to see that method print cannot be redefined.
<...
-7
votes
1
answer
99
views
How can I pass a class type into a method and use it to create new objects of the class? [closed]
I have a situation where I have multiple csv files that I want to transform into various objects. So I have something like:
...
0
votes
2
answers
198
views
How do I correctly bind to / observe a non-observable object within SwiftUI?
I have a view, TimeEditView, that edits an object of an Item class I made. The class does not conform to ...
0
votes
1
answer
87
views
How to reference current property value in class property attribute in PHP 8.4?
I've done a lot of Googling and may have missed this, there's so many examples of using the new Attribute feature in PHP but none of them show if this is possible. What I would like to be able to do ...
1
vote
2
answers
74
views
Vector from Class objects vector as 2D vector function parameter
Solution requirements:
Pre C++11
Statements:
Function someFunction exists, that accepts 2D vector as vector of string vectors: ...
-1
votes
1
answer
111
views
Proper way to pass a class around SwiftUI views [closed]
I have a SwiftData class that I get with @Query private var items: [Item] in a SwiftUI view. Then I pass it to a sub view that passes it to other sub views. What is ...
1
vote
1
answer
69
views
In Lisp can't make-instance because :name isn't provided
This code creates an error: The slot COMMON-LISP-USER::NAME is unbound in the object
#<THING {1002B830F3}>.
I tried sbcl and clisp, both creating same problem. I can initialize instance of ash ...
-1
votes
1
answer
113
views
Why doesn’t method overriding in Python affect the base class instance?
I'm a bit confused about how method overriding works in Python.
Let's say I have a base class with a method, and I override that method in a subclass. When I call the method from the subclass, the ...
0
votes
3
answers
127
views
Minifiying javascript file with webpack breaks vue functionality (specifically with method calls on class instance)
I am working on an ASP.NET project that uses Vue.js and jQuery. I have a JavaScript file (fields.js) that defines several classes (e.g., Users, Fields) and initializes a Vue instance. When I use the ...
1
vote
1
answer
189
views
Declareing array that stores a struct, which defined in another file included, gives the error "Incomplete Type "Array[]" is not allowed"
I have defined a struct in another file called file1.h (example) and when I declare an array using that struct in another file called File2.h, i get the error Message:
"Incomplete Type "...
3
votes
1
answer
60
views
Using a class with numpy does not work correctly
I define an array of 4 corners
...
6
votes
0
answers
87
views