Questions tagged [constructor]

2 votes
1 replies
`std::filesystem::path::operator/(/*args*/)` not working as expected
I have a class with an initialiser list in the constructor where one of the fields I'm initialising is a std::filesystem::path but it doesn't see...
asked 4 months ago
4 votes
2 replies
React - constructor function [duplicate]
This question already has an answer here: Is it better to define state in constructor or using property initializers?...
asked 4 months ago
4 votes
2 replies
How to cout a constructor?
I'm kinda new to C++ and i got this problem while learning about it So I have created this class class A { int num; public: //construct...
asked 4 months ago
1 votes
1 replies
How can I instantantiate an object of a class created in other file?
Hi I'm new at javascript and I can't instantiate an object of another class, I have summarize it in a simple example. When I run foo.js I got the...
asked 4 months ago
2 votes
2 replies
I changed the default constructor for my class, but seems compiler still calls the default constructor
I create a class A, and overwrite operator+ and constructor A(A&&), I am wondering if I call A a, b; A c = a + b; Is my constructor A...
asked 4 months ago
0 votes
1 replies
No appropriate default constructor available templates
I have a problem when i created an template object, i have a constructor but the program said that doesn't exists a correct constructor. What is...
asked 4 months ago
0 votes
1 replies
How do you create a constructor that takes an array of “Range” objects and initializes the list, list is intialized to an ArrayList
I am having trouble creating a constructor that takes an array of Range objects and initializes the list – list should be initialized to an Array...
asked 4 months ago
5 votes
1 replies
How to apply the `__ramfunc` instrinsic to a constructor?
I need to put all my code in ram (I'm writing the flash). I'm using IAR 7.80 and everything works fine with the __ramfunc intrinsic on every func...
asked 4 months ago
-1 votes
0 replies
Ho to pass value to base class constructor by derived class constructor?
I have a problem with some code. Basically the problem request to build a class Employee that acquire some data and store them in a file, startin...
asked 4 months ago
3 votes
1 replies
Which part of standard determines priority of in-place member vs initializer list?
I just made a sample, which from my personal point of view should not compile, or at least give a warning, but Visual Studio 2017 does not give a...
0 votes
0 replies
Using object methods within its constructor [duplicate]
I have a constructor function which registers an event handler: function MyConstructor(data, transport) { this.data = data; trans...
asked 4 months ago
0 votes
3 replies
How can i find specific new object of Class that has a constructor argument equal to input
I have a class called Country with 4 constructor parameters. I then create some new countries from that class with specified values. My questio...
asked 4 months ago
0 votes
2 replies
Transforming child constructor params for parent constructor in Kotlin
I'm a Java veteran who's learning Kotlin. I'm finding myself a bit mystified about how take constructor parameters provided to a child class and...
asked 4 months ago
0 votes
1 replies
Why is my object declared but never read (within a function)?
I'm fairly new to Javascript. I only started messing around with it a couple of months ago and I've run into an error that I can't seem to work a...
asked 4 months ago
0 votes
2 replies
Problem: cannot resolve constructor CSVPrinter
I'm trying to generate and load from CSV filea and problem with CSVPrinter occured. The statement is the following: Cannot resolve constructo...
asked 4 months ago
0 votes
1 replies
How do I initialise a Class with parameters [duplicate]
This question already has an answer here: A field initializer cannot reference the nonstatic field, method, or property...
asked 4 months ago
0 votes
1 replies
How does setting the value of a Property in the constructor call work with JsonProperty?
This line of code works, but I'm not sure why it does. [JsonProperty("id", Required = Required.Always)] To me this seems to be setting a value...
asked 4 months ago
0 votes
1 replies
Getter method is returning wrong values [closed]
I have a constructor that takes a String and turns that String into a date. However when I run my main code, I get random dates that are not corr...
-1 votes
0 replies
Java: Parameterized base constructor is not called if derived class constructor is missing [duplicate]
How to inherit the constructor from a super class to a sub class? 36 6 Answers 6 Con...
asked 4 months ago
0 votes
0 replies
Java Wrapper Method for a constructor
I have a Course class with its constructor: public class Course extends AbstractSubmission { private String course_content; public Co...
1 votes
2 replies
How to do constructor for 2D vector in C++?
I tried initializing a 2D vector with a constructor in 3 different ways but always get an "error: no matching function to call" Could you tel...
-2 votes
0 replies
Copy Constructor not copying array [duplicate]
I am doing a project for school and it requires a copy constructor, destructor, etc. When I use the copy constructor an error is thrown saying th...
asked 4 months ago
1 votes
2 replies
Copy constructor not deep copying, error returning with array empty
I am doing a project for school and it requires a copy constructor, destructor, etc. When I use the copy constructor an error is thrown saying th...
asked 4 months ago
0 votes
1 replies
Efficient way to construct object with string member
Suppose I have a class ThisHasAStringMember. Assume it has a private member which is a string, and I want to efficiently get the string value, pr...
asked 4 months ago
2 votes
2 replies
Restricting creation of object in a singleton class using constructor in python
I am middle of writing a singleton class for one of the requirement in python. I could realize that I am not able to restrict the object creation...