Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [constructor]

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

-1 votes
0 answers
26 views

When I call the constructor in the main program, the default values are getting displayed. I want the values initialized in the default Constructor() [duplicate]

When I call the constructor in the main program, the default values are displayed. I want the values initialized in the default Constructor(). Why constructor overloading is not happening when I ...
Tanuja Naik's user avatar
1 vote
1 answer
51 views

C++ overload resolution problem: How to make vector fill constructor overload instead of vector initializer list construtor?

#include <vector> #include <iostream> using namespace std; int main() { vector<char> v1 = { size_t(0),0 }; vector<char*> v2 = { size_t(0),0 }; cout << v1....
iouvxz's user avatar
  • 137
-1 votes
0 answers
32 views

Unity C# using "new Color(0,0,0,1) " doesnt do anything in inspector

So basically, as stated in the title. I have a variable set to [SerializeField] Color textColor = new Color(0,0,0,1); and it does absolutely nothing in the inspector. I could set that color to ...
Mike The Elf's user avatar
-1 votes
0 answers
51 views

Pass collection to constructor from xaml [closed]

I have a problem with passing elements collection to a constructor from xaml. Is there a solution to pass multiple arguments to constructor from xaml? An example of what I want to achieve: In c#: ...
Pavel Abramovich's user avatar
-1 votes
0 answers
48 views

Is it possible to have a constructor with multiple parameters, only to use few of the possible parameters on initialization? [duplicate]

In other words, is it possible to use only few parameter on initialization of a class, even when the constructor has multiple parameters? Or is there a way to do so, without having to make a ...
user16393738's user avatar
1 vote
1 answer
29 views

initializing inline and initializing inside constructor which does run first in Typescript?

I'm learning about class concept in typescript. I recognize that there are two ways to initialize fields (properties) in typescript: initializing inline the class body and initializing inside the ...
LeoPkm2-1's user avatar
1 vote
0 answers
21 views

PHP 7.4 is ignoring incorrect parameter passing [duplicate]

I have the following class with the following constructor: class Film { private string $name; private int $releaseYear; private string $genre; private array $notes = []; public ...
Pedro Schinke's user avatar
0 votes
1 answer
25 views

How to do self-contained Lazy Initialization using async/await

I am trying to initialize a class asynchronously using dependency injection. I have seen this article https://blog.stephencleary.com/2013/01/async-oop-2-constructors.html but I am trying to initialize ...
Nick Tucker's user avatar
2 votes
2 answers
93 views

How to return smart pointers and covariance in C++

I am following this tutorial to understand how to return smart pointers and covariance in C++. #include <memory> #include <iostream> class cloneable { public: virtual ~...
GPrathap's user avatar
  • 7,670
3 votes
1 answer
51 views

Multiple constructors annotated with Lombok @Builder cause a problem?

This is my first question, so please feel free to correct anything that I missed writing this question:) I am having trouble with using the @Bulider with my DTO objects. I have an abstract class "...
Doh Kun Lee sanity's user avatar
5 votes
3 answers
178 views

Initialization order of inherited constructors

I have this example: #include <iostream> #define print(X) std::cout << X << std::endl struct B1 { B1(int _i = 5): i(_i) { print("B1 constructor"); }; int i; }; ...
mada's user avatar
  • 1,932
-2 votes
0 answers
13 views

Why constructor cannot access static variable inside the constructor block?

Why static variable can't be accessed using this keyword inside a constructor I created a static variable and a no argument constructor inside a class when I try access the static variable with the ...
Yogi's user avatar
  • 1
-3 votes
0 answers
55 views

Why java is not giving me default constructor [duplicate]

package com.vedantkakade; class Student { String fname; String lname; public void printInfo() { System.out.println(fname + " " + lname); } Student(Student ...
Vedant Kakade's user avatar
0 votes
2 answers
76 views

Use of deleted function std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&)

I am currently trying to set up a very basic Entity Component System. For this, I have defined the following classes: class Component { public: virtual ~Component() {}; // Ensure polymorphic ...
notfynnaf's user avatar
0 votes
0 answers
51 views

I was trying to create class mystack which would work like a stack datatype but i encountered unexpected output

This is the code where i tried to implement stack in c++ without pointer instead i used a interger variable called "top" to hold the current position of stack and also i created constuctor ...
Dushyanth Yadav v's user avatar

15 30 50 per page
1
2 3 4 5
1410