Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
97 views

The scala project is depending on the Java lib that I cannot modify. I need to extend one of the Java classes and override method, however I have issues with protected visibility: package com.a; ...
Hedrack's user avatar
  • 786
1 vote
1 answer
112 views

I'm new to Haskell and can't figure out if I'm mixing up concepts or if it's just a syntax error eluding me. I have a function which expects to return an "Expr" type - a custom data type I'...
Glenn Jansson's user avatar
0 votes
0 answers
46 views

I am using DefaultMessageListenerContainer as below : private static final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MessageConsumer.class); public ...
sstkoverflowcoder's user avatar
0 votes
3 answers
626 views

So this is the part of my code that contains the constructors. As you can see, the purpose is to have the constructors take in less parameters and call the most specific constructors. I thought I ...
Justin 's user avatar
0 votes
3 answers
205 views

I have to write a code that prints a triangle which the length of the last line is the input number. Also the empty spaces have to be filled with dots. It has to look like this. Also, the code has ...
Felix's user avatar
  • 1
0 votes
2 answers
63 views

I have a base class with a default constructor. class Base { public: Base(); private: Type1 m_ofType1; Type2 m_ofType2; } Base::Base() : m_ofType1(defaultExpr1) , m_ofType2(...
brandon_busby's user avatar
0 votes
1 answer
582 views

I have two constructors in FirebaseUserAuth class and it is giving an Error: declaration have same java signature. The parameter of constructors are different. Why is it giving same signature error? ...
Askani's user avatar
  • 468
0 votes
0 answers
153 views

I'm aware that multiple constructors in python is not possible. However, I found the range class has two __init__ signatures from the official docs. class range(stop) class range(start, stop[, step]...
Jeffery Li's user avatar
4 votes
2 answers
7k views

This is an anti pattern, but I am curious what will actually happen. If you explicitly define a no-args constructor and a constructor with an autowired parameter, how exactly will spring framework ...
Bato-Bair Tsyrenov's user avatar
1 vote
4 answers
246 views

I have a class where one of its members is ArrayList<ArrayList<Double>> elements, and so I have a constructor that takes in that same type and all is good. public elementArray(ArrayList&...
Alex Jones's user avatar
2 votes
3 answers
7k views

Why does this not compile? class test { constructor() { var a = Date().day this(a) } constructor(a:Int) { } } error is: Expression 'this' of type 'test' cannot be invoked as a ...
user3561494's user avatar
  • 2,382
-2 votes
1 answer
472 views

I am writing some genetic algorithms in python. Currently I was looking at a book that has java code, so but eventually I am trying to write my own Adaptive Genetic algorithm to optimize neural ...
Matt  Ward's user avatar
0 votes
1 answer
408 views

I need to have a Scala class HugeDecimal that inherit from java.math.BigDecimal. It cannot be a trait for internal reasons. The following simple implementation: class HugeDecimal extends java.math....
marcprux's user avatar
  • 10.5k
1 vote
2 answers
809 views

Here when I run this below code I get called as the output and I was wondering why not called new. Since 1 comes under both short and int range. public class MyClass { private int x; ...
Coder17's user avatar
  • 883
0 votes
0 answers
251 views

In a scenario where a class has multiple constructors I understand that Castle Windsor has an algorithm used to detect the 'greediest' constructor and pick that one to resolve a component. But why ...
mihalios's user avatar
  • 848
1 vote
3 answers
1k views

I am not really sure how this works, but if I want to give the option for giving more or less variables to an object of a class, would this work with multiple constructors like this? Let's say I ...
Sky Mage's user avatar
3 votes
1 answer
191 views

I'm doing an assignment based around inheritance and I have created 2 constructors that are suppose to do different things. One constructor does not have any parameters and should produce a pre-...
user7128699's user avatar
1 vote
1 answer
2k views

I have been instructed to do the following: Create a constructor with no arguments in Carnivore that call the super constructor in Animal. Carnivore is a sub class of Animal which is the super class. ...
Harry's user avatar
  • 109
0 votes
3 answers
408 views

Question about chaining constructor with Class Parameter. I have a Form with a list box. This form is for debug purpose. When I instanciate all my object (Class) I want them to write in this list box ...
JudgeDreed's user avatar
0 votes
2 answers
4k views

I'm looking for help troubleshooting this code. My assignment is to make a blog which I can make multiple new articles on. I am using an event listener, linked to the submit button. But when I run the ...
user7023766's user avatar
-1 votes
1 answer
695 views

I'm from C++, and i try to understand JS OOP. But I have to admit it isn't simple ... I want to create a "simple" class. Like this : class Being { Being(float A, float B) {...} Being(string A, ...
Olivier.B's user avatar
  • 119
2 votes
1 answer
1k views

I have hit a little problem with constructors at my program. It is a simple bank database which stores customer data. I have to implement methods for depositing, withdrawing and transferring cash ...
Michał Matuszewski's user avatar
0 votes
1 answer
111 views

I have a Java class that I am trying to rewrite into Scala. It has 3 constructors that need to be available even though I am only using 1. public class EntityNet extends EntityThrowable { @...
Dyonovan's user avatar
0 votes
0 answers
84 views

This is a corner I have painted myself into a few times. I would have thought given how common alternate constructors are in Python that it would not be unheard of to construct a subclass from an ...
Victor's user avatar
  • 127
2 votes
1 answer
65 views

So i am having trouble wrapping my head around an issue, current working on a midi player that reads a file using buffered reader. i am reading the each object from the file as a string into an array ...
Kammryn Dancy's user avatar
0 votes
1 answer
74 views

I want to do the following: // I want to do this! :D - (instancetype) init { return [self initWithVal1:[NSDecimalNumber zero] val2:MyEnumDefault]; } - (instancetype) initWithVal1:(...
Ky -'s user avatar
  • 32.4k
4 votes
2 answers
191 views

I have following class, written so, as to work completely, whatever the typedef is: class A { protected: typedef uchar mDataType; std::vector<mDataType> mData; uint32 mWidth; ...
MKK's user avatar
  • 140
1 vote
1 answer
183 views

I liked the idea presented in this answer allowing having something like multiple constructors in PHP. The code I have is similar to: class A { protected function __construct(){ // made ...
Voitcus's user avatar
  • 4,456
1 vote
3 answers
79 views

I am having a class SomeClass with the following member fields and the constructors private int someInt; private String someStr; private String strTwo; //the contructors public SomeClass() {} // ...
De-Great Yartey's user avatar
0 votes
0 answers
31 views

I am having trouble trying to figure out why my program is not printing the user input (plane ids,capacity). I edited my code so when the user selects print planes print plane info it works fine. ...
Noah Kettler's user avatar
0 votes
1 answer
130 views

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CodyGarrettEX3 { public class Account { private long ...
Cody's user avatar
  • 127
1 vote
3 answers
710 views

I don't understand what happens when you create a Rational object with the constructor Rational(). My book says it will create a Rational object whose value is 0 but internally stored as 0/1. How does ...
Jessica M.'s user avatar
  • 1,459
12 votes
6 answers
878 views

Assume I have a non-copyable class with multiple constructors with like this class Foo: boost::noncopyable { public: Foo(std::string s) {...}; // construct one way Foo(int i) {...};...
Roddy's user avatar
  • 68.5k
0 votes
3 answers
7k views

Hi Guys I'm having error regarding Duplicate Constructors, but according to my Assignment i need a another constructor but different field. Specifications: Meeting – Location, Subject, list of ...
user3617072's user avatar
3 votes
2 answers
421 views

I know that I can do that with ': this()' but if I do that the overloaded constructor will be excecuted first and I need it to be executed after the the constructor that will call it . . . . Is ...
Yoiku's user avatar
  • 912
3 votes
3 answers
2k views

Is it possible to define an alternate parameterless constructor for a C# class? In other words, I have a class Foo. I want to have a default constructer Foo() and another constructor SpecialFoo(). ...
William Jockusch's user avatar
2 votes
2 answers
98 views

I'd like to write a program which creates a set of objects in a loop.... (i.e.) String newFirm = "empty"; for(int i=0; i<30; i++) { newFirm = "firm" + i; firm newFirm = ...
Apollo Creed's user avatar
0 votes
1 answer
148 views

I want to be able to create a constructor that can call on its types but without any constraints. public class Box { public class Command { public string name; public string ...
albert Silva's user avatar
3 votes
1 answer
212 views

I have been learning Scala, it has been so good so far, sadly i have found certain behaviour that i don't fully understand. I hope you guys can give me some clues, the problem emerged when i coded ...
Ryogakaji's user avatar
1 vote
2 answers
824 views

I am trying to unit test (in java) a piece of code which has several constructors and some with logic in them. So apart from setting some fields, the constructors may affect certain static objects ...
B M's user avatar
  • 671
11 votes
4 answers
1k views

I have tried many solutions found in google by the keywords: multiple constructors, scala, inheritance, subclasses. None seems to work for this occasion. ImageView has three constructors: ImageView(...
George Pligoropoulos's user avatar
-2 votes
4 answers
1k views

OK, I need to create three constructors as part of a project, one default, one general and one copy. I've managed to create a default constructor, but I can't create either the general or copy ...
Keith Francis's user avatar
11 votes
5 answers
21k views

I would like to have two constructors for a class, as follows: public MyClass() { // do stuff here } public MyClass(int num) { MyClass(); // do other stuff here } Is the above the ...
CJ7's user avatar
  • 23.4k
3 votes
4 answers
7k views

I want a subclass to use its parent's constructors. But it seems I always need to define them again in the subclass in order for that to work, like so: public SubClass(int x, int y) : base (x, y) { ...
Alessandro Ituarte's user avatar
4 votes
3 answers
2k views

I'm trying to create a generic class like this: class A[T](v: Option[T]) { def this(v: T) = this(Some(v)) def this() = this(None) def getV = v } Then I do some testing: scala> new A getV ...
Vilius Normantas's user avatar
8 votes
2 answers
14k views

How to implement php constructor that can accept different number of parameters? Like class Person { function __construct() { // some fancy implementation } } $a = new Person('...
hoyomi's user avatar
  • 287
8 votes
3 answers
2k views

In C# regarding the inheritance of constructors: I have read that constructors cannot be inherited. If the base class contains a constructor, one or more, the derived class have to always call one of ...
JeffreyZ.'s user avatar
  • 385
5 votes
6 answers
214 views

In the C++ programming for the absolute Beginner, 2nd edition book, there was the following statement: HeapPoint::HeapPoint(int x, int y): thePoint(new Point(x,y)) { } Is this equal to: HeapPoint::...
Simplicity's user avatar
  • 49.4k
8 votes
2 answers
5k views

is it possible to have more than one constructors for a class in javascript? i.e. one with zero parameters, one with one, one with two, etc... if so, how? thanks!
clamp's user avatar
  • 34.2k
8 votes
5 answers
3k views

There seems to be no language syntax for specifying both a this() and a base() constructor. Given the following code: public class Bar : Foo { public Bar() :base(1) //:this(0) { } ...
Sprague's user avatar
  • 1,638