Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
100 views

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 ...
Zedarc7's user avatar
  • 33
1 vote
2 answers
89 views

Let's say I have this code: class MyClass { constructor() { return {}; } } const x = new MyClass(); // how many objects are instantiated with this? I know that variable x just holds ...
user3163495's user avatar
  • 4,046
1 vote
0 answers
120 views

Here's a piece of Qt code: int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QGuiApplication app2(argc, argv); The first constructor call returns, the second does not. I ...
Ivan's user avatar
  • 451
-5 votes
3 answers
217 views

Consider passing a shared pointer of const std::shared_ptr<Object> to the ctor of following class. struct MyClass { explicit MyCLass(const std::shared_ptr<const Object> & input) : ...
Alex Suo's user avatar
  • 3,177
2 votes
2 answers
123 views

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 ...
Ben's user avatar
  • 539
3 votes
6 answers
210 views

I have some tricky code that I need to initialize many objects that refer to each other. I want to allocate and construct them all at once, so I put them all in a struct. It looks like this: // User ...
Guillaume Racicot's user avatar
1 vote
1 answer
93 views

So I’m kinda stuck wrapping my head around this whole parent-child dependency thing. My assumption was, once you declare all the dependencies in the parent (BaseController), the child (like ...
Joey's user avatar
  • 93
-1 votes
0 answers
35 views

While I was learning the language, I became interested in primitive types and their object wrappers. While I was in my code editor discovering this language feature, I discovered that any of these ...
d10's user avatar
  • 1
-2 votes
4 answers
152 views

I'm working on a .NET application where every command/query handler needs access to three shared services: IValidator, ISecurity and ILogger. Rather than manually injecting these into each handler ...
Mahmudul Hasan's user avatar
4 votes
1 answer
74 views

I have the following: class A: def __init__(self, x): self.x = x A(5) # Works fine x = A.__new__ # Save the function A.__new__ = lambda y: y # Temporarily override it A.__new__ = x # ...
user9185231's user avatar
1 vote
2 answers
118 views

I want to create a variable of type Foo. The class Foo consists of a variable called Bar bar_ which is filled directly in the constructor initialization. The thing is, class Bar has a reference to the ...
peter's user avatar
  • 59
6 votes
1 answer
250 views

I'm getting a compiler error about a type conversion that should be legal, to my eyes. Let's say I have a home-grown string class, convertible from and to char*: class custom_string { public: ...
Peter Yurkosky's user avatar
1 vote
1 answer
89 views

I'm trying to learn constructors and statics and I'm not sure what I'm doing wrong here controller <?php namespace App\Http\Controllers\Api; use App\Models\SampleModel; class SampleController { ...
rhemmuuu's user avatar
  • 1,209
2 votes
1 answer
48 views

My error is SiteChecker is not a function I was following this guy steps https://www.thepolyglotdeveloper.com/2020/06/scan-broken-links-website-javascript/ to set up package and execute , but on my ...
Nina Mishchenko's user avatar
0 votes
1 answer
123 views

I'm trying to explicitly instantiate a forwarding constructor using C++20 with GCC 13.3 compiler in order not to put its definition in the header file. Here is a minimal example: Foo.h #pragma once ...
bobeff's user avatar
  • 3,771
2 votes
1 answer
144 views

I have this record: record Foo { string _bar = "initialized"; public string Bar => _bar; } I'm running the following code: var foo = new Foo(); Console.WriteLine(foo?.Bar ?? &...
Ivan Petrov's user avatar
  • 7,544
1 vote
1 answer
69 views

In the example, there is a "match redundant" Error, indicating that SOME s is matching on every string and not the provided s: fun matchs (s : string) : (string option -> bool) = fn x =&...
qwr's user avatar
  • 11.6k
0 votes
1 answer
101 views

import 'dart:typed_data'; class Test { Uint8List testKey; Test({this.testKey = Uint8List(0)}); } Gives compile error: Error: Cannot invoke a non-'const' factory where a const expression is ...
user1624503's user avatar
0 votes
1 answer
51 views

I'm trying to create classes that can be saved to a JSON file. The idea is to convert my object to a dataclass that stores only the important attributes. I'll then use something from json or ...
Quantasm's user avatar
3 votes
2 answers
84 views

The code is not an ideal implementation, but it demonstrates something interesting. I have a class template with some bool parameters, where specializations of the class have slightly different ...
Spencer's user avatar
  • 2,254
0 votes
1 answer
54 views

the below outputs true, meaning that new memory is not allocated for different objects, but they point to the same prototype Noob. function Noob(name, game) { this.name = name; this....
Leafy's user avatar
  • 3
0 votes
1 answer
150 views

I'm trying to write some UI-Code (for learning purposes) and I get this error that I can't find a fix to. The 4 errors are `E0493` No instance of overloaded function "UIElement::UIElement" ...
greifer500's user avatar
6 votes
1 answer
241 views

Given this declaration: type TRec = record FNr: integer; FName: string; constructor Create(ANr: integer); end; and this implementation of the constructor: constructor TRec.Create(ANr: ...
Anders G's user avatar
1 vote
1 answer
70 views

I know of two ways to call a superclass's constructor from a derived class: super().__init__() and base.__init__(self). Why does the second require me to explicitly supply self as an argument? Here's ...
ok akkx's user avatar
  • 21
2 votes
3 answers
186 views

In C++ inheritance, I understood that subclass's constructor cannot directly initialize the members of the parent class. If it is so, why doesn't the code below cause an error? class Person { ...
ValExi's user avatar
  • 157
2 votes
3 answers
127 views

I have a class which uses a fixed number of member classes (mInpA, mInpA in my case) class csAndGate : public csLogicCell { public: csAndGate() : mInpA(this), mInpB(this) {} ...
jokn's user avatar
  • 170
0 votes
1 answer
145 views

Consider a class where I'm using brace initialization for data members to provide default values at declaration. If I also want to provide a reset() function, is there anything wrong with calling the ...
coderoo's user avatar
  • 75
11 votes
1 answer
206 views

I would like to make a class that satisfies std::copy_constructible concept and in addition can be constructed from an arbitrary copy constructible value much like std::any does: #include <concepts&...
Fedor's user avatar
  • 24.8k
1 vote
1 answer
65 views

A simple class with a copy constructor, which calls another constructor: public class Foo<TEnum> where TEnum : Enum { public Foo(TEnum myEnum) { MyEnum = myEnum; } public Foo(Foo<...
lonix's user avatar
  • 22.5k
7 votes
2 answers
223 views

I have a following header: #include <string_view> #include <tuple> std::tuple<int, int, int> foo(std::string_view sv); class s { public: s(std::string_view sv); ...
Dominik Kaszewski's user avatar
0 votes
3 answers
141 views

I would like to make a constructor with an optional parameter, to avoid giving in Strings all the time, because I need to use the constructor like a thousand times, so I would like to call methods ...
Agnes Nycs's user avatar
-3 votes
2 answers
89 views

I'm writing a WPF app and am trying to test its click events quickly. As a first attempt, I called the click events in the constructor. These functions are async void so I wrap them with Task.Run()....
muon2's user avatar
  • 1
4 votes
1 answer
106 views

In C++, you can inherit all constructors of a base class by writing using Baseclass::Baseclass My Baseclass has both a default constructor and another one that takes an int argument, even though that ...
DRman's user avatar
  • 41
3 votes
1 answer
132 views

For this simple classes below. For MyClass, the constructor initializes str with s during construction using the intializer list. Does this mean that str doesn't get constructed at all yet until mc ...
Engineer999's user avatar
  • 4,159
1 vote
0 answers
75 views

Here is a quick experiment to demonstrate an inconsistent behaviour: trait Foundation { import Foundation.* { initialisationCounter.incrementAndGet() } case class Top1() { } } object ...
tribbloid's user avatar
  • 3,832
-1 votes
1 answer
119 views

Take this very simple class. The main() function just creates an object of it. Even though the constructor and destructor don't have an implementation here. My assumption is that the constructor will ...
Engineer999's user avatar
  • 4,159
0 votes
0 answers
73 views

I am thinking about stack unwinding when an exception is thrown here. In the below simple example, when throw 505 is executed, from what I understand, the stack starts to unwind until it finds the ...
Engineer999's user avatar
  • 4,159
1 vote
3 answers
116 views

I have a class with a default constructor which initializes many member variables via initializer lists. I wish to have a parametrized constructor which only updates one of the member variables. A ...
Engineer999's user avatar
  • 4,159
0 votes
2 answers
165 views

I would like to create a class in C#, where some of the property need to be set after a call to a database. A a crude example example: I want to create a shipping class for some furniture objects. In ...
Aurel's user avatar
  • 111
0 votes
2 answers
46 views

I am trying to instantiate a singleton with constructor argument. However, passing the input arguments to the metaclass hits an error. from typing_extensions import List, TypedDict, Optional, Any ...
khteh's user avatar
  • 4,290
1 vote
0 answers
86 views

I refactored some code and now my unit test is crashing. The code being tested runs fine in the project, but when I inherit from the class in the test fixture there is an error when running the ...
agmessier's user avatar
0 votes
0 answers
101 views

I have a thread_local variable, which should initialize a class in every thread, but the constructor isn't called, when the threads are opened. The constructor is only called, when I place the ...
user avatar
1 vote
2 answers
321 views

I have the following record. But the collection cannot be null. Is there a way to default it to an empty list if it's null? public record Car( long id, String model, List<...
S.Dan's user avatar
  • 1,940
-1 votes
5 answers
160 views

Probably like many devs, I've picked up practices etc. based on the existing code as well as conversations with colleagues. A question just occurred to me, and I'm not sure if this is a 'best practice'...
Donagh's user avatar
  • 145
2 votes
1 answer
122 views

I'm new to C++ and I have a task: create a class that represents a point on a 2D coordinate plane and then create 3 constructors: one that will define both coordinates and a name (consisting of a ...
Фёдор Руденко's user avatar
2 votes
3 answers
151 views

What is a way to define a member object variable of a class that can either be passed into the constructor (ownership stays external to class) or constructed inside the class's constructor (ownership ...
kfpgk's user avatar
  • 85
1 vote
1 answer
260 views

I have an Angular Firebase app with "@angular/cdk": "19.0.4", "@angular/common": "19.0.5", "@angular/compiler": "19.0.5", "@angular/...
Weeedooo's user avatar
  • 451
0 votes
1 answer
78 views

I am using ANTLR 4, and it is common to instantiate a class and immediately pass it as the argument of the next class' constructor, as per the docs for the ANTLR 4 JavaScript target: import antlr4 ...
James Baw's user avatar
0 votes
2 answers
211 views

I create a new project in java springboot. When I try to run the code it gives the following error. D:\Project\New folder\demo\src\main\java\com\example\demo\controller\EmployeeController.java:15:35 ...
Madavi Fernando's user avatar
1 vote
1 answer
88 views

Please see following C++ code: #include <iostream> using namespace std; class alpha { int a; public: alpha () {}; alpha (int c) { a = c; } void showalpha (...
Vinayak Deshmukh's user avatar

1
2 3 4 5
424