Questions tagged [overloading]

A type of polymorphism where different functions with the same name or different implementations of an operator are invoked based on the data types of the parameters passed. DO NOT USE FOR OVERLOADING IN PHP; THE MEANING OF THAT TERM IN PHP IS UNRELATED.

The terms overloading and overloaded may refer to:

Don't confuse it with

Related tags:

6857 questions
4
votes
2 answers

How can I overload a method with @QueryParam in Jersey/Spring?

I would like to overload a method with the @QueryParam but everytime I try to execute this code it throws: SEVERE: Exception occurred when intialization com.sun.jersey.spi.inject.Errors$ErrorMessagesException My code…
Grammin
  • 11,808
  • 22
  • 80
  • 138
3
votes
5 answers

Differentiating between generic and non-generic version of overloaded method using reflection

I'm having some trouble using reflection to differentiate between a non-generic and a generic method on a generic class. Here's a test case I'm working with: public class Foo { public string Bar( T value ) { return "Called Bar(T)"; } public…
LBushkin
  • 129,300
  • 32
  • 216
  • 265
3
votes
4 answers

function overloading can only be done by return value and const in C++?

Is it possible to have two versions of the same function which are the same except for return type and constness ? I do not think so. The following example shows that. But I do not know the reason. #include using namespace std; class A { …
user1002288
  • 4,860
  • 10
  • 50
  • 78
3
votes
4 answers

JavaScript overloading with a callback

Following the pattern recommended in this question, where we have something akin to: function foo(a, b, opts) { } foo(1, 2, {"method":"add"}); foo(3, 4, {"test":"equals", "bar":"tree"}); How would one then include a callback as the final…
Unpossible
  • 10,607
  • 22
  • 75
  • 113
3
votes
4 answers

Double dispatch in C# 4.0 - dynamic keyword?

I realise this has been asked before, but I didn't find a clear agreement on the best solution. Is using dynamic (like below) the best way to do this? I guess its best to avoid dynamic whenever possible to help catch problems at…
gwizardry
  • 501
  • 1
  • 6
  • 19
3
votes
4 answers

Function Overloading in TCL

Are there any packages or any specific way to support function or procedure overloading in TCL?? This is my scenario. I need to write a generic procedure that accepts two or 3 files, wherein I may or may not have the third file (File3) …
user1270123
  • 563
  • 5
  • 11
  • 21
3
votes
2 answers

Overload * operator in python (or emulate it)

I want to overload the * operator in python. In C++, you can overload the dereference operator, so that you can create a class with a custom way to respond to *alpha. Part of this question is that I don't know exactly, and I mean EXACTLY, what the *…
norcalli
  • 1,215
  • 2
  • 11
  • 22
3
votes
3 answers

Difference between function overloading and method overloading

Hi I am trying to understand the difference between function overloading and method overloading in c++. After googling I came across this. not sure if this is correct. If wrong pls help in correction. Method overloading and function overloading are…
user995487
  • 141
  • 2
  • 2
  • 9
3
votes
5 answers

Scheme programming sum function overloading

Define a function sum, which takes two numbers, or two real functions, and returns their sum. E.g. (sum 1 2) => 3 ((sum cos exp) 0) => 2 I get that for the sum of two numbers the code would be the following: (define sum (lambda (x y) (+ x…
user1028
  • 31
  • 1
  • 3
3
votes
2 answers

Why can't I access a public function that has a protected overload?

Given the code: class Foo { public: Foo() {} int foo() const { return 6; } protected: int foo() { return 5; } }; int main(int argc, char* argv[]) { Foo foo; foo.foo(); return 0; } I get a compile error: 'Foo::foo' :…
neuviemeporte
  • 6,310
  • 10
  • 49
  • 78
3
votes
4 answers

Is it possible to overload Func and Func having the same name?

First of all, I know I can just define two overloaded helper methods to do what I need (or even just define two Func<>s with different names), but these are only used by one public method, so I'm exploring ways to define two local Func<>s that also…
Erhhung
  • 967
  • 9
  • 14
3
votes
2 answers

Generic interface overloading for methods?

Is there a good, generic, way to do the following without resorting to a second method or lots of casts - I want to keep the API as light as possible and it seems ok to me OO-wise: class Foo { public T Bar() where T: IAlpha { /*…
fortescu
3
votes
2 answers

How to overload a function which calls an overloaded version of itself?

Fraction Fraction::pow (Fraction frac, int power) { Fraction temp; temp.num = pow(frac.num, power); temp.den = pow(frac.den, power); return (temp); } // Assume that num and den are float and cmath is…
Balaji Sridharan
  • 339
  • 1
  • 5
  • 7
3
votes
7 answers

Java: "Class Overloading"

Okay, so let's say I have a class file called Orange, and then two separate class files called Color, and Fruit. Inside Orange, there are some properties for color, size, ripeness etc. and the method setSize(int size). Inside Fruit, there are some…
Blackvein
  • 558
  • 4
  • 10
  • 23
3
votes
1 answer

How do I intercept PDO calls?

I'm trying to implement a plugin API in a PHP-based product I'm working on. I created a class that inherits from PHP's PDO class and then added some extra methods. Trouble is, I want to intercept things like PDO's .query(), .exec(), .execute(), and…
Volomike
  • 23,743
  • 21
  • 113
  • 209
1 2 3
99
100