Skip to main content
-7 votes
0 answers
54 views

What's the difference between initializing an object by passing in variables to the constructor or through the brackets? What would be the proper use case of either method? public class MyClass() { ...
CocoaMix86's user avatar
21 votes
1 answer
1k views

I have pinned a strange compilation error to this minimal code example: #include <iterator> #include <type_traits> struct A { class iterator { private: int i = 0; // compiles if &...
phinz's user avatar
  • 2,101
-3 votes
1 answer
323 views

I am making several template classes and their non-initialized declarations give errors E3158 and E0289, indicating that my compiler cannot identify the class's template arguments. What is a way ...
Sir Is-Ikke Null-a-ton's user avatar
2 votes
0 answers
76 views

I was wondering if it's possible to get the object constructor from within an R6 object. One obvious way would be something like this: test <- R6::R6Class('test', public = ...
luigidolcetti's user avatar
Best practices
0 votes
8 replies
53 views

Let's say I have a class with many parameters. In Typescript, this is how the class is created: class ClassName { private para1: string para2: boolean para3: number = 6 protected ...
Sul4ur's user avatar
  • 1
3 votes
1 answer
116 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
97 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,036
0 votes
0 answers
127 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
  • 559
-5 votes
3 answers
224 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,187
2 votes
2 answers
137 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
  • 603
3 votes
6 answers
220 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
98 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
-2 votes
4 answers
173 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
76 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

15 30 50 per page
1
2 3 4 5
1412