Skip to main content
Filter by
Sorted by
Tagged with
3 votes
2 answers
106 views

Given a wrapper type template <typename T> struct Ptr { Ptr(T*); }; a class hierarchy struct Base {}; struct Derived : Base {}; and a set of function overloads void f(Ptr<Base>); ...
Michael Deom's user avatar
1 vote
1 answer
98 views

If I have a class constructor with two overloads taking in different inputs, is there a way to tell them apart? For example, class example { double ExampleDouble; char ExampleChar; public: ...
yes's user avatar
  • 19
0 votes
0 answers
63 views

I am designing a container (yeah, do not reinvent the wheel, I know). Let's call it Container<T>. I have a constructor to allow the initial number of elements: explicit Container(std::size_t ...
LeDYoM's user avatar
  • 999
1 vote
0 answers
51 views

I'm on a team with two other devs. For the past few months I've been working on a project in C# 12 independently, and only recently have the other devs pulled my code and run it. For one of them it ...
mdirks's user avatar
  • 73
1 vote
0 answers
183 views

I have a Managed Record named TEmail with a nested private class called TEmailForm that inherits from TForm. The idea is my email Record can create a modal form as needed for the user to type an email....
dallin's user avatar
  • 9,514
0 votes
2 answers
56 views

public class Sample { int id; String name; int age; Sample(int i, String n){ id = i; name = n; } Sample(int i, String n, int a){ id = i; ...
koolest's user avatar
1 vote
1 answer
99 views

I have a class Vec<C> that works as below, and I need to know a way to write the constructor and/or deduction guide such that a braced-enclosed initializer list deduces C as std::array<T,N>...
Astor's user avatar
  • 394
2 votes
3 answers
164 views

I am trying to implement a list container in C++, and I have problem with compiler selecting the wrong constructor overload. The constructors are as follows: list(size_type count, const T& value); ...
Emre Erdog's user avatar
3 votes
1 answer
169 views

Consider the following two classes: struct Base { Base() = default; Base(auto&&); }; struct Derived : Base { using Base::Base; }; If I try the following test with Type = Base and ...
Dr. Gut's user avatar
  • 3,335
0 votes
1 answer
55 views

I am attempting to create an overloaded contructor that will take in integer and add them with the byteAdd function. However; whenever I compile the output is always the default constructor rather ...
Steven Osi's user avatar
1 vote
2 answers
169 views

I am writing a small library for working with polynomials. The main class is called poly and it contains 4 overloaded constructors. An object of class poly is a representation of one polynomial. Full ...
Bartłomiej Konecki's user avatar
3 votes
2 answers
964 views

I am porting a project from Java to Python and there is a class with multiple constructors. I'm trying to port that same idea to python, in a pythonic way. I've recently been informed of the typing....
CraneStyle's user avatar
0 votes
0 answers
31 views

Hi I'm trying to learn java This a simple program that stores a patient's blood details, well in any case how can i keep the program accurate by means of returning an error message if the input was ...
Annika's user avatar
  • 1
1 vote
2 answers
761 views

I am working on a class PlaybackControl, I use it to create two HTMLElements: PlaybackControlButton: HTMLButtonElement PlaybackControlMenu: HTMLDivElement Now, to initialise the class object, I need ...
D V's user avatar
  • 416
1 vote
1 answer
1k views

If in C++ a class had an overloaded constructor: class MyClass { std::string name; public: MyClass(){}; MyClass(std::string name_){ name = name_;} }; how do I expose this to python? Can I ...
sodiumnitrate's user avatar
1 vote
1 answer
55 views

I have some code for a abstract Binary Tree class with nodes. I have an add(value : N) method and and add(value : E)that just takes an element and automatically creates the Node. As you can see below ...
Luke Abruzese's user avatar
0 votes
0 answers
32 views

I am working on a solo project and I find myself using very often the following: list_obj = list(map(func, list_obj)) I want to just add the map functionality to the list class to avoid bloat and ...
George's user avatar
  • 135
-1 votes
1 answer
95 views

I have 4 instance variables that can be initialized by default, is the code written below appropriate? The number of constructors is growing a terrible pace, will I use the Builder object that have ...
Gor Madatyan's user avatar
0 votes
1 answer
849 views

I was reading the book by Joyce Farell on C++, and it's saying that a default constructor is the one with no arguments. I understood it without any hiccups. But things started getting worse after it ...
CREATIVITY Unleashed's user avatar
0 votes
1 answer
276 views

I am trying to implement constructor overloading by using byte, short and long together. I am passing three values from main method and want to check which constructor gets called Test(byte, short, ...
user9342976's user avatar
1 vote
2 answers
562 views

I am trying to implement constructor overloading by using int and long together and double and float together. I am passing two int values from main method and want to check which constructor gets ...
user9342976's user avatar
3 votes
2 answers
218 views

I'm trying to create a dictionary with structural equality in F# and I want to pass through several dictionary constructor overloads. In C# this would look like class StructuralDictionary<Key, ...
farlee2121's user avatar
  • 3,415
2 votes
2 answers
227 views

I have the class as follows: class A{ private: int a; int b; int c; public: A(int a1){ a1 >= 0 ? a = a1 : a = -1; } A(int a1, int b1, int c1) : A{ a1 }, b{ b1 }, c{ ...
user avatar
4 votes
0 answers
47 views

I have two almost identical implementations of the __new__ method for a class. However, in one case, there is an error message. In the other case, it works fine. class Klass1(): # causes ...
Toothpick Anemone's user avatar
2 votes
1 answer
2k views

What is the way to show all the overloads of a constructor in C++ in Visual Studio 2022? Suppose I have a Rectangle class, and I have 3 overloads for them. When I hover my mouse in any of them, ...
Rubayat26's user avatar
  • 333
-2 votes
2 answers
89 views

I have a User class that has two constructors. When I create an object and use the two constructors, one of them gives me an error saying: no match for call to '(User) (double&, double&, ...
Rosan Syal's user avatar
2 votes
2 answers
158 views

I know and I have read many threads to call a base class constructor from a Derived class, But I wanted to implement it using Delegating constructors Here is my code The error states "A ...
Shivang Mathur's user avatar
4 votes
4 answers
118 views

I have a simple class with a constructor of all available fields and i want to add an overloaded constructor with varargs to allow the creating of objects even if some fields are unknown. class ...
wannaBeDev's user avatar
1 vote
1 answer
79 views

In the following snippet I have reconstructed a small failing example of what I'm working on right now. The class entity should be able to gobble up different "functor" types, hence it has ...
glades's user avatar
  • 5,374
1 vote
1 answer
146 views

This code below is working fine, but it gives an error for the resolve constant. const resolve: Resolve Type '(param: "case 1" | "case 2" | "case 3") => boolean | &...
Yacine's user avatar
  • 753
0 votes
2 answers
382 views

i'm newbie in this world currently i'm learning java and i wanna to know why i can't use multiple this() in a constructor someone can tell me why please? public class Student { private String ...
Ayoub Bentameur's user avatar
-2 votes
1 answer
676 views

I have an overloaded constructor in C++ (default + other). My automatically generated pybind code looks like this: py::class_<MyClass>(m, "MyClass") .def( py::...
thzu's user avatar
  • 63
1 vote
1 answer
91 views

What determines which constructor is used if a Generic class has 2 constructors: One takes (T data), and another (string errorMessage). And an instance is created with type string? For me it seems to ...
Feargal Kavanagh's user avatar
0 votes
0 answers
44 views

why is the constructor Number() not being invoked when a number data type is initialized without any values ? #include <iostream> using namespace std; class Number { int n; public: ...
user19811991's user avatar
2 votes
1 answer
251 views

Help me solve this puzzle: In the following code I have an std::variant which forward declares a struct proxy which derives from this variant. This struct is only used because recursive using ...
glades's user avatar
  • 5,374
1 vote
1 answer
340 views

please find below code. In this code, when I use "placement new", the I see segmentation fault in constructor, I am not sure why it is causing this, since I can create normal objects. Also, ...
Coder's user avatar
  • 843
0 votes
3 answers
173 views

I just want to know if we can use overloading constructor with the same number of variables, same data types with the different variables. Employee(String firstName, String lastName, String jobRole){ ...
filocoderist's user avatar
0 votes
2 answers
5k views

Assume a function that takes an object as parameter. There could be various ways to express the parameter object creation, some of which expressive, and likely easier to be used. To give a simple ...
Mukesh C's user avatar
  • 143
0 votes
2 answers
85 views

I have a diamond inheritance scheme in C++ solved through virtual inheritance. The base class is general has two attributes and some method using them. class general { double attr1, attr2; public: ...
Rafael's user avatar
  • 129
1 vote
1 answer
227 views

Here's something I'm trying that doesn't seem to work: I want to toggle a compile time switch based on how a class object is instantiated. If there's just one constructor argument, the LengthOpt ...
glades's user avatar
  • 5,374
1 vote
1 answer
494 views

Just a question RE: Constructor Chaining in subclasses that I can't find a good answer on and I'm confusing myself a bit with. I'm making a basic little Text Based RPG for some practice and I'm going ...
Conor Timlin's user avatar
0 votes
0 answers
26 views

I'm sure this question exists elsewhere, but can't find an answer. I've noticed that when a constructor is defined as deleted, it makes that type take part in overload resolution. In other words, if ...
Robert's user avatar
  • 525
-1 votes
1 answer
51 views

Question: s= "campaign_5Nu_E_0_87872_shard1.zip" desired output: campaign5Nu_E_0_87872shard1.zip Guys help me........
Sneha Rani's user avatar
0 votes
1 answer
75 views

This is about c# constructors and has been asked before a couple of times. However, the questions and answers never really fit my scenario: public abstract class BaseClass { public List<int>...
Ingmar's user avatar
  • 1,487
0 votes
2 answers
305 views

We made a dynamic array class during lecture and the instructor copy-pasted the copy_constructor code on the assignment_operator_overload. But don't we need to delete the existing dynamic array first ...
VoidRust's user avatar
0 votes
1 answer
712 views

I've designed a simpler wrapper class that adds a label to an object, with the intent of being implicitly convertible/able to replace the wrapped object. #include <string> #include <...
joaocandre's user avatar
  • 1,767
1 vote
1 answer
82 views

According to https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view, std::basic_string_view class has 7 overloaded ctors. I only care about 2 of them since right now I don't use ...
digito_evo's user avatar
  • 3,735
1 vote
2 answers
498 views

I am learning C++ and playing around with OpenCV and node-addon-api. I wanted to create my own wrapper for cv::Vec. docs #include <napi.h> #include <opencv2/core/matx.hpp> class Vec : ...
Michal's user avatar
  • 5,273
21 votes
1 answer
1k views

To allow std::string construction from std::string_viewthere is a template constructor template<class T> explicit basic_string(const T& t, const Allocator& alloc = Allocator()); which ...
oliora's user avatar
  • 918
0 votes
4 answers
457 views

I am trying to overload a constructor in java. There are two Strings among its variables which is problematic if I write two separate constructors in the case of only one of these strings being called....
user avatar

1
2 3 4 5