79,869 questions
Advice
1
vote
3
replies
62
views
Creating classes/class objects in JS - perhaps jQuery, not sure
What is this?
(function (Skd, $, undefined) {
title = "SkdInternal"; // internal?
#title = "SkdPrivate"; // private?
Skd.title = "Skd"; // public?
Skd....
Best practices
0
votes
4
replies
77
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 ...
Advice
0
votes
4
replies
110
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 ...
-3
votes
1
answer
241
views
C++ matrix class' operator* returns wrong answer [closed]
I've been tasked to write a code which implements a matrix class with a typical set of matrix operations, for example multiplying matrices with entries taken mod 1000 (EDIT: the dimensions are bounded ...
0
votes
1
answer
74
views
Automate removal of div/span attributes for code clean-up and easier merging
<span class="SpellingError SCXO166867203 BCX8" style="margin:0px;padding:0px;background-repeat:repeat-x;background-position:left bottom;">bv</span><span class="...
2
votes
2
answers
102
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 class attributes as the leaves of a ...
1
vote
3
answers
113
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 that inherit the parents, and they ...
-3
votes
1
answer
99
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:
#nullable enable
using System.Collections.Generic;
// Biology.dll
public abstract class Animal
{
...
-5
votes
1
answer
136
views
calling a class object in an iterative way on python
I made the next class
obj = MyClass()
fds=['a','b','c']
for i in fds:
attribute_name = f"{i}"
setattr(obj, attribute_name, [f"{i}"])
print(obj.i)
I know that obj.i is ...
-4
votes
4
answers
168
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 is the same as a the name of one of ...
0
votes
1
answer
90
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 ...
2
votes
1
answer
100
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 the type of a a (variant) variable, eg VarType 2 returns integer and ...
2
votes
1
answer
145
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:
sqlalchemy.exc....
0
votes
2
answers
160
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 my code.
#include <iostream>
#include <fstream>
#include <chrono>
#include <thread>
#...
-7
votes
1
answer
97
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:
#What works
car = []
with open("car.csv") as csv_file:
data = ...
0
votes
1
answer
82
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
votes
1
answer
103
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 the best way to pass the class ...
-1
votes
1
answer
106
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 ...
2
votes
1
answer
180
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 "...
6
votes
0
answers
84
views
The memory usage of the __dict__ of instances of a class
import sys
class Vector:
def __init__(self, x, y):
self.x = x
self.y = y
v1 = Vector(1, 2)
v2 = Vector(1, 2)
print(f"v1 __dict__ : {sys.getsizeof(v1.__dict__)} bytes")
...
0
votes
0
answers
62
views
PHP Class Object Shopping Cart Data Storage Problem
H I am trying to store my shopping cart variables using Classes/Objects for integration with Klarna. The following code works great on testing but I now need the Cart (products) to be dynamically ...
0
votes
1
answer
68
views
Run time error related to main method error
I'm currently studying Java in general and inheritance in particular.
When I run the code below in an online editor it throws an error related to the main method, however, when I modify it as ...
-1
votes
1
answer
105
views
Why doesn't javac generate a new .class file after renaming the class?
Why doesn't javac generate a new .class file after renaming the class?
My file name is Test.java.
Case #1:
class example {
public static void main() {}
}
When I compiled this using javac Test....
0
votes
0
answers
14
views
Add class to header with javascript works in MAMP but not online
I'm trying to add an extra class at my header to change the logo on scroll. I used the tutorial mentioned in the code as a guide and that works in MAMP (local) but not online. Local it does add the ...
1
vote
1
answer
113
views
Why does the friend template function have different behaviors for struct and class?
#include <array>
template<std::size_t tc_n>
requires (tc_n > 0)
struct StringLiteral final {
std::array<char, tc_n> value{};
consteval StringLiteral(char const (&sl)[...