Questions tagged [constructor]
A special type of subroutine called at the creation of an object.
152 questions
0
votes
0
answers
18
views
Mathematica implementation of Lempel method for constructing Costas arrays
I ported C++ implementation of Lempel method for constructing Costas arrays to Mathematica.
How to fix my code? Thanks in advance.
...
2
votes
0
answers
34
views
Mathematica implementation of Welch method for constructing Costas arrays
I ported C++ implementation of Welch method for constructing Costas arrays to Mathematica.
Any feedback would be appreciated.
...
2
votes
1
answer
99
views
Using std::variant for constructor
Need some input on using std::variant for the constructor.
The top section explains why I have so man constructors. The review is really about the last bit of code ...
3
votes
1
answer
270
views
Presence of UB and memory usage of a std::array initialization
I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539.
A classical way to answer would be to use std::index_sequence-based ...
2
votes
1
answer
125
views
in_place_constructor helper type
recently I implemented a little helper class, which can be primarily utilized on perfect forwarding constructors.
Introduction
As a slight example, let me pull in two of the ...
1
vote
2
answers
213
views
A simple String class and its special member functions
I am learning the behavior of C++'s special member function, using a naive String class as example. (The code is modified from this tutorial) Here is the ...
6
votes
2
answers
1k
views
Classes representing 2D points and pixels
How can I improve this code or make it tidier?
...
1
vote
1
answer
82
views
Tiny Validity class
Here is a part of my new code replacing the old and deprecated old-school one.
Let's get to business right away:
I document everything with Documentation comments, which are proving very useful so ...
6
votes
3
answers
267
views
Performing complex operation before calling the primary constructor in Kotlin
Semester is a simple enum class.
...
0
votes
1
answer
174
views
GameObject - Component hierarchy, component can access game object in constructor
While creating a game engine using c++, when defining a component, I was tired of writing down essential but repeated elements such as 'GameObject* parent' every time I define a new component ...
2
votes
2
answers
144
views
Setting instance variable for salary bonus based on academic position
I have a class Scholar which is basically a teacher in a university. I have to calculate the yearly salary of a scholar instance where the formula is ...
0
votes
1
answer
80
views
If constructor has actions besides assignment should I move those actions in separate method?
I have class CellGroup that contains List of cell lists
That class has creation of list inside and transforming it to list of lists.
...
0
votes
2
answers
202
views
Made a monster array for a text based game with a class constructor C++ [closed]
I created a class in a separate .h and .cpp file with the idea of having an array of 3 monsters with each monster having different stats( name; health; damage). The problem is that the constructor ...
4
votes
1
answer
321
views
Commands Object creation using chained Builder pattern
Context
As many of you may know I have a library that allows C++ objects to be converted into JSON/YAML/BSON automatically with a single declaration (see previous code reviews).
I am now (trying) ...
10
votes
2
answers
755
views
Clearing up property and field confusion in C#?
I understand that creating public properties that control private fields is good practice because of coupling and encapsulation, although lately I have seen it as such a waste of boilerplate code for ...