Skip to main content
The 2024 Developer Survey results are live! See the results

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.

0 votes
0 answers
24 views

Javascript: Any way to create a class by constructing class name using strings/variables dynamically without eval?

I've tried myriads of ways to create new class instances dynamically, without using eval and hard coded key-value pairs, to no avail. Seemingly there is no way in modern Javascript to query the user ...
MalackaPower's user avatar
0 votes
0 answers
15 views

Prevent VS Code suggesting turning a function into a class

I have an issue with VS Code suggestion turning a function in JS into a class. It gives the following suggestion message: This constructor function may be converted to a class declaration. ts(80002) ...
tacoshy's user avatar
  • 12.1k
1 vote
0 answers
35 views

PHP - Issue when adding a return type declaration for a parent class [closed]

I have currently have the following classes: class Textarea Extends Field {} class Field {} I'm trying to declare a return type for the following function public function field(string $field): Field ...
Jackatron's user avatar
0 votes
0 answers
22 views

Why re-assign class methods to `this` in constructor in tappable Hook class?

Here is the code in webpack tappable source code: class Hook { constructor(args = [], name = undefined) { this._args = args; // ... this.compile = this.compile; this.tap = this.tap; ...
Strawhat's user avatar
-2 votes
0 answers
48 views

Compare two maps where the values are class objects [closed]

I'm trying to compare two hashmaps where the values are class objects. I know the .equals() for the class can be overridden so it would compare the values rather than instances but what if the class ...
Kel243's user avatar
  • 23
0 votes
1 answer
34 views

R Reference Class Add New Variable by Name

Consider the following R code : MyClass <- setRefClass("MyClass", fields = list( ), methods = list( initialize = function(x){ #give new attribute x ...
温泽海's user avatar
  • 344
1 vote
0 answers
18 views

How to import a library from VBScript into another asp file using Jscript?

I'm Having trouble trying to import a library written in VBScript to another asp file written with Jscript. Im new to both script languages, however I was wondering if it was possible to cross-use ...
Cayetano Molina's user avatar
0 votes
2 answers
35 views

access a component in a tkinter frame class from another frame class

I created a 2 Frames application in tkinter inspired by https://www.geeksforgeeks.org/how-to-change-the-tkinter-label-text/. The purpose is to import a new image by clicking on the start button, and I ...
Sticonike's user avatar
0 votes
1 answer
29 views

Can a generic Blazor Component handle multiple classes with the same structure?

I have created a Blazor Component to handle editing a database record which is defined by a class. I would like this component to be reused to edit other records - that have the same structure, but ...
Paul Pritchard's user avatar
-3 votes
0 answers
21 views

How to Structure an Optimization Program Like Pyomo Using Only Functions Instead of Classes? [closed]

Pyomo is a popular Python library for formulating and solving optimization problems. It uses an object-oriented approach where variables, objective functions, and constraints are defined as attributes ...
elo98's user avatar
  • 1
-1 votes
0 answers
59 views

Why is constructor called, not overloaded operator=? [duplicate]

In the following code (also here: godbolt) Why is the constructor for myParam called in the assignment in main() and not the operator= overload? What can I do to force the assignment? Thanks! #include ...
Paul Sheppard's user avatar
-11 votes
0 answers
63 views

What's the difference between 'ClassName* p' and 'ClassName p'? [duplicate]

Please explain to me the difference between Player p and Player* p. Why should I write it like this: Player *p = new Player(playwin, 1, 1, '#'); while (p->getmv() != 'x') { p->display(); ...
Иванов Леонид's user avatar
0 votes
0 answers
12 views

set value for conditional initializer property in class model

given below was my model: public class RelationContentTypeObject { [JsonProperty("$id")] private string IdField { get; set; } [JsonProperty("$ref")] private string ...
Harikarthik's user avatar
1 vote
1 answer
40 views

Typescript how to get type of optional properties of class or interface

class Load { ID: number; Action?: string; public getType(name: string) { return typeof this[name]; } constructor() { } } let _load =new Load() _load.ID = 5 ...
once in an blue moon's user avatar
1 vote
1 answer
80 views

How do I use std::reference_wrapper to store the reference in an std::unordered_map?

I'm trying to learn the use of std::reference_wrapper and std::ref and the use cases of it. Here is a sample code I wrote. Please help me solve the compilation error. And it would be great if you can ...
Aman Kumar's user avatar

15 30 50 per page
1
2 3 4 5
5326