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

php no overloading inside static function

i dont seem to understand why the code below only prints "TEST" two times. "; public static function getInstance() { return new self(); } public static function someStaticMethod()…
Marc
  • 139
  • 7
4
votes
3 answers

Execution flow of Method overriding and method hiding

I'm confused with the following scenario, we have a set of classes like this public class A { public virtual string SomeMethod() { return "A"; } } public class B : A { public override string SomeMethod() { return…
Vamsi
  • 4,237
  • 7
  • 49
  • 74
4
votes
3 answers

Linq to SQL SP parameters

I have a SP which I want to call from linq. The SP have 5 parameters but i only want to pass/need to 2 of them. how would I call the SP as when i go to add the parameters in code it wont build as it want all 5.
MartGriff
  • 2,821
  • 7
  • 38
  • 42
4
votes
3 answers

Method overloading with interface in Java

I have a behaviour that I don't understand with overloading in Java. Here is my code: interface I {} class A implements I {} class B { public void test(I i) {} public void test (A a) {} } When I call the following line: I a = new A(); …
Kiva
  • 9,193
  • 17
  • 62
  • 94
4
votes
2 answers

Java Challenge as Listed in Java Programming for the Absolute Beginner

This is probably an elementary question. However, I have completed reading the 5th Chapter of Java Programming for the Absolute Beginner and have approached the Challenges section. I cannot quite understand the question. The question asks:…
user1604490
4
votes
1 answer

Finding method overload count in Java

In some projects I am currently working on, method overloading is being misused in many classes: methods with the same name are being overloaded for many times just with the difference of a parameter's presence or absence. And I want to change…
Ryan Li
  • 9,020
  • 7
  • 33
  • 62
4
votes
2 answers

const and non-const function overloading

We have const and non-const function overloading in C++ as described here and used in STL iterators. Do we have such method overloading in Java and C#?
zeropoint
  • 235
  • 1
  • 4
  • 10
4
votes
2 answers

no match for operator+ error with operator overloading

I'm going through the gameinsitute's c++ programming course and there is an example for operator overloading and i'm constantly getting a main.cpp|20|error: no match for ‘operator+’ in ‘v + w’ and i have no idea where the problem is. main.cpp //…
lajb
  • 51
  • 3
4
votes
2 answers

Using reference in overloaded function using __call()

class a { public function f(&$ref1, &$ref2) { $ref1 = 'foo'; $ref2 = 'bar'; } } class b { public function __call($methodName, $arguments) { $a = new a(); call_user_func_array(array( …
Jon Skarpeteig
  • 4,118
  • 7
  • 34
  • 53
4
votes
5 answers

Is method overloading a form of polymorphism or something else?

I have a long standing doubt. Could someone please tell me whether method overloading is a form of polymorphism or is it something completely different?
crowso
  • 2,049
  • 9
  • 33
  • 38
4
votes
4 answers

no overload for method 'METHOD' takes 0 arguments

I have 3 methods. 1 method holding the value of 3000 1 method holding the value of 0.13 and I have created another method that I want to multiply these two figures together. public override int FishPerTank() { return 3000; …
Simagen
  • 409
  • 2
  • 8
  • 18
4
votes
4 answers

Overloaded constructors in C# similar to Delphi (with multiple names)

I am trying to port some code from Delphi to C# and I have found a construction which I cannot implement in a reasonable manner, while complying with .NET Framework design guidelines (which I address at the end of my question). Obviously C#, Java,…
4
votes
3 answers

Calling Methods of Anonymous Inner Class in the parent class

I got the below doubt when am surfing about Anonymous inner class Here is the Original code I downloaded and was working around it (please refer to the below code only for my questions). As per the link above they say we cannot overload & add…
Sudhaker
  • 785
  • 1
  • 6
  • 13
4
votes
2 answers

C++ overloading operator<<

I'm trying to overload the << operator for a class to emulate toString() in Java. I have a NumExpr class, and has private variable number that I want to output. so here they are: NumExpr::NumExpr( string n ) { number = atoi( n.c_str()…
Jason Hu
  • 1,237
  • 2
  • 15
  • 29
4
votes
2 answers

Bug on a custom C++ class

I need help on finding the problem using a custom c++ class to manage 3D positions. Here is the relevant code from the class Punto operator+(Punto p){ return Punto(this->x + p.x, this->y + p.y, this->z + p.z); } Punto operator+(Punto…