FAQ Database Discussion Community


Are type hint and default param value also method signature?

php,class,oop,interface,method-signature
Example : The interface is public function doFoo($bar); Can I have a class implementing the interface with method public function doFoo(array $bar = array('test')) { } What does the method signature mean in PHP? Is it just the method name and parameter name ? Or, type hinting and default values...

How to avoid calling a too much parameterized constructor, with virtual inheritance?

c++,constructor,virtual-inheritance,method-signature
I want to perform a virtual inheritance with the following obvious example : class A { public: A(int a) : m_a(a) {} private: int m_a; }; class B : virtual public A { public: B(int a, int b) : A(a), m_b(b) {} private: int m_b; }; class C : virtual...

Why does Stream.Write not take a UInt?

c#,.net,method-signature,cls-compliant
It seems highly illogical to me that Stream.Write uses int, instead of UInt... Is there an explanation other than "legacy" code for this fact? Would any one want to write -1 bytes?!?

Why does the Java equals(Object O) method not have a variant which can take a specific object type (e.g. String, Integer, etc) as input?

java,generics,equality,string-comparison,method-signature
I come across problems where I need to compare two strings (or any other object ) for equality/non-equality using Java language. There are two methods on String Object very useful for this purpose viz. compareTo(Object O), which returns a integer result of comparison while other equals(Object o), which returns a...

Changing signature while Overriding in C++

c++,default-value,overriding,method-overriding,method-signature
I have a base class class Shape{ public: virtual int getArea()=0; } I want to change the signature while overriding like this: class Rectangle : class Shape{ public: int getArea(int someParameter = 0){ return 0; } } Is it possible somehow to achieve this, as I am using default value...

Java Bytecode Signatures

java,generics,jvm,java-bytecode-asm,method-signature
As part of the compiler for the programming language I am working on, I came across generic signatures in the bytecode, which I am trying to parse and convert to an AST. The parsing algorithm mostly works, but there seems to be a special case in which the format of...

What's the principle to define an interface with dependencies?

java,design,inversion-of-control,method-signature
Which dependency should locate in a method signature as a param and which should not? Since we have IoC container like spring, most of the dependencies could get injected through it. For java.util.concurrent.Executor: public interface Executor { void execute(Runnable command); } The interface could be public interface Executor { void...

Why am I getting “onCreate(Bundle) already defined”?

java,android,signature,method-signature,method-names
I'm trying to produce several buttons which open different links but by copying the file over I get an error saying onCreate(Bundle) is already defined? Is it because I have two protected void onCreate(Bundle savedInstanceState) { or something? Please add a description to what is the issue and possibly an...