Skip to main content

Questions tagged [constructor]

A special type of subroutine called at the creation of an object.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

I ported C++ implementation of Lempel method for constructing Costas arrays to Mathematica. How to fix my code? Thanks in advance. ...
138 Aspen's user avatar
  • 469
2 votes
0 answers
34 views

I ported C++ implementation of Welch method for constructing Costas arrays to Mathematica. Any feedback would be appreciated. ...
138 Aspen's user avatar
  • 469
2 votes
1 answer
99 views

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 ...
Loki Astari's user avatar
  • 97.7k
3 votes
1 answer
270 views

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 ...
Oersted's user avatar
  • 337
2 votes
1 answer
125 views

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 ...
DNKpp's user avatar
  • 791
1 vote
2 answers
213 views

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 ...
Der Fänger im Roggen's user avatar
6 votes
2 answers
1k views

How can I improve this code or make it tidier? ...
user366312's user avatar
1 vote
1 answer
82 views

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 ...
Vlastimil Burián's user avatar
6 votes
3 answers
267 views

Semester is a simple enum class. ...
Hyeonseo Yang's user avatar
0 votes
1 answer
173 views

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 ...
김범무's user avatar
2 votes
2 answers
144 views

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 ...
tmo's user avatar
  • 33
0 votes
1 answer
79 views

I have class CellGroup that contains List of cell lists That class has creation of list inside and transforming it to list of lists. ...
DozezQuest's user avatar
0 votes
2 answers
202 views

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 ...
Nis's user avatar
  • 9
4 votes
1 answer
321 views

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) ...
Loki Astari's user avatar
  • 97.7k
10 votes
2 answers
755 views

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 ...
Josh Hallow's user avatar
  • 1,355
2 votes
1 answer
71 views

I have an abstract Badge class, every class extending this class should always correctly set the incoming name (string) and achievedAt (date) fields. There might be other classes that extend the Badge ...
Miguel Stevens's user avatar
0 votes
2 answers
134 views

I'm using PHP, I have a class that generates an id based on the calling class, so the id of the class won't change after it has been initialised, now I'm wondering which of my two methods is ...
Miguel Stevens's user avatar
4 votes
1 answer
605 views

A similar question was asked here, and I'm trying to do the same thing. But I'm trying a different approach by deriving from std::array, and This is a very focused ...
holomenicus's user avatar
-1 votes
1 answer
720 views

I have Java (or C#, Python, Kotlin, or other similar language) class that will be used to communicate with client over network. Protocol used by this application allows many different ways to create ...
jiwopene's user avatar
  • 159
4 votes
1 answer
347 views

I'm playing around with making random items and decided to implement the following structure. ...
BlueLightning42's user avatar
1 vote
1 answer
85 views

I've created some controller for handling clicked links statistics. Does this class meet Single Responsibility Principle? ...
Szymon Czembor's user avatar
1 vote
2 answers
804 views

The code below is a custom array class that handles indexing, copying, printing, etc. explicitly. Is there a better approach for specification (declaration and definition) of the assignment operator (...
Darnoc Eloc's user avatar
1 vote
2 answers
225 views

This is part of a Particle Swarm Optimization algorithm, a snippet of a Particle class implementation. ...
gator's user avatar
  • 455
0 votes
3 answers
168 views

This is a class representing a city in a mod I am creating for Minecraft. All the constructor parameters are mandatory and they are used to help the class that calculates and builds the Paths, ...
Vpant's user avatar
  • 139
2 votes
1 answer
188 views

I want to reduce boiler-plate code and write like this when developing in iOS: let imgView: UIImageView = "share_fareware_text_bg" Here is implementation code: <...
black_pearl's user avatar
2 votes
1 answer
574 views

I'm trying to write a constructor function that generates instances of a user. One of the properties of the user class is an array of the user's hobbies. I'd like ...
Anthony's user avatar
  • 191
1 vote
1 answer
53 views

Consider Crate::addLength() in the following code: ...
Dennis's user avatar
  • 281
4 votes
1 answer
94 views

I am making a subclass of a well-established python class: pendulum.Period, which overrides both __new__ and ...
Brandon Kuczenski's user avatar
5 votes
1 answer
161 views

Out of curiosity I was discovering the potential of the Ellipsis object in Python (...), and I discovered it doesn't do a whole ...
moltarze's user avatar
  • 455
2 votes
1 answer
80 views

As many of you know goto is usually signs of code smell. However I thought this could be an appropriate case, and would like confirmation or criticism. Unnecessary ...
utkumaden's user avatar
4 votes
2 answers
2k views

To practice my c++ I decided to implement a simple Kafka producer to wrap the producer in c in librdkafka library. I just want to get your opinion on the way I have implemented teh default, copy and ...
kovac's user avatar
  • 269
3 votes
2 answers
350 views

During some running process, a histogram of values shall be build up. When done, the CDF shall be derived from it and used to get the quantiles for some values. My current implementation looks as ...
Tobias Hermann's user avatar
0 votes
3 answers
109 views

I have a class which represents some translations of a keyword. ...
Patrick's user avatar
  • 131
5 votes
2 answers
569 views

I have an inheritance class that mimics the behavior of C style array's brace initialization by using a class template that has a variadic constructor but the template itself is not a variadic ...
Francis Cugler's user avatar
3 votes
1 answer
802 views

The objective of the post is to improve design and improve command on C++. Given a map, start point and end point, the shortest path to end point from the start point has to be found out using Astar (...
skr's user avatar
  • 539
3 votes
1 answer
367 views

My requirement is, I need to load the existing xml file from the given path by passing through command line arguments and need to update the xml file from C# code. First time I am working on the C# ...
prakash's user avatar
  • 31
0 votes
2 answers
1k views

I have this item (an item is an object linked to a xml view), to build it I need 2 things, get labels from codes, and get text from the strings.xml android file. please ignore the long to int and int ...
sliders_alpha's user avatar
-1 votes
2 answers
2k views

Assume that we have a class with multiple constructors which may look like the following: ...
Ayoub Falah's user avatar
0 votes
2 answers
146 views

Let's say I have an abstract class Character that have fields health and maxHealth. maxHealth...
Emre's user avatar
  • 113
3 votes
1 answer
125 views

I've written a program following the instructions of an exam paper. There are no solutions available so I would appreciate a feedback. I'm concerned with main in ...
agneau's user avatar
  • 341
4 votes
1 answer
252 views

I am working on cleaning up and making open source a C++ reflection library that has served me well over the last few years. One of the most important classes of the library is ...
zennehoy's user avatar
  • 143
1 vote
4 answers
309 views

I'm a beginner i have an assignment to write a Date class (as part of a bigger project). in my question i focus on the constructor. here's some background: the given guidelines are that the date is ...
Eric Parker's user avatar
1 vote
2 answers
971 views

Here's what the question asks: Build a class called Course.java. This class should have 4 properties: CourseId, CourseName, Description, and credit hours. Also add the appropriate set and get ...
Marc's user avatar
  • 11
2 votes
1 answer
5k views

I have a project where I want to build a more sophisticated ToDo list - basically a personal project management system. I'm just starting out with the project, and I'd like some feedback on whether my ...
Frauke's user avatar
  • 139
3 votes
1 answer
1k views

I am trying to create a class to test my understanding, and it takes an ArrayList as parameter. The decision of choosing an ...
ManuAlvarado22's user avatar
3 votes
4 answers
181 views

Maybe someone can help me to optimize the calculate method. I think that it can be simplified from that what I have now. The objective is: grab a string via the ...
Sviat Kuzhelev's user avatar
0 votes
2 answers
342 views

Is there a little "better" way of writing the line: raise RuntimeError if not radius.is_a? Numeric or radius == 0 I want to only allow numbers bigger than 0. <...
NullCod3's user avatar
2 votes
2 answers
1k views

I'm quite new to Go and would like to improve my code. I have a representation for access levels in Go like this: ...
Michael Lihs's user avatar
5 votes
2 answers
406 views

Below you can find the constructor method and related fields of the main class of my REST API (note that the class contains more code than displayed) written in PHP 7.1. It does various things with ...
Belle's user avatar
  • 207
0 votes
1 answer
2k views

I have to create a constructor that allows a new linked list to be populated with ten consecutive values, starting at 0. Then I need to print the list! So i want to check if the functions I wrote for ...
jimm bo's user avatar