How to return an array from a function?

int* test(); but it would be “more C++” to use vectors: std::vector< int > test(); EDIT I’ll clarify some point. Since you mentioned C++, I’ll go with new[] and delete[] operators, but it’s the same with malloc/free. In the first case, you’ll write something like: int* test() { return new int[size_needed]; } but it’s not … Read more

Inheritance best practice : *args, **kwargs or explicitly specifying parameters [closed]

Liskov Substitution Principle Generally you don’t want you method signature to vary in derived types. This can cause problems if you want to swap the use of derived types. This is often referred to as the Liskov Substitution Principle. Benefits of Explicit Signatures At the same time I don’t think it’s correct for all your … Read more

Does a method’s signature in Java include its return type?

Quoting from Oracle Docs: Definition: Two of the components of a method declaration comprise the method signature—the method’s name and the parameter types. Since the question was edited to include this example: public class Foo { public int myMethod(int param) {} public char myMethod(int param) {} } No, the compiler won’t know the difference, as … Read more