Skip to main content
Filter by
Sorted by
Tagged with
-5 votes
0 answers
79 views

We cannot instantiate an inner class within a static context of the outer class, but when we declare this inner class as package- private. we are able to access its constructor. But how ? what is the ...
Hüseyin Çataloğlu's user avatar
-5 votes
3 answers
198 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,167
3 votes
6 answers
200 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
0 votes
0 answers
34 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
4 votes
1 answer
73 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
6 votes
1 answer
246 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
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
2 votes
1 answer
133 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,339
0 votes
1 answer
77 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
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
146 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
1 vote
1 answer
69 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
117 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
11 votes
1 answer
203 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.7k
7 votes
2 answers
208 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
-3 votes
2 answers
81 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
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 votes
1 answer
118 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
1 vote
3 answers
114 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
40 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,280
0 votes
0 answers
94 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 votes
5 answers
157 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
3 answers
148 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
0 votes
1 answer
72 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
1 vote
1 answer
85 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