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
3
votes
2 answers

Function Overloading for the standard library functions in C++

I have a free function as part of a class. In the constructor for the class i am doing some malloc operations . So in the destructor i am trying to free that memory. But VS10 compiler complains that the free(pointer); doesn't match the signature…
Jay D
  • 3,263
  • 4
  • 32
  • 48
3
votes
1 answer

vb.net specilized/overloaded generics

I tend to loath repetition in code, so when I come across a problem where the only different is types I tend to use generics. Coming from a C++ background I find vb.net's version to be rather frustrating, I know C++ has template specialization and I…
Apeiron
  • 694
  • 7
  • 13
3
votes
2 answers

Powershell: C#-style function overloads with Parameter Sets?

In C#, function overloading has historically appeared something like the following, where each overload adds some amount of parameters on top of the simpler signatures: public void Initialize(int version); public void Initialize(int version, string…
bwerks
  • 8,651
  • 14
  • 68
  • 100
3
votes
7 answers

How to overload a method at run-time or other ideas in C#

Maybe overloading a method is not exactly what is necessary but this is the best i could come up with. I have a class: public class Worker { private string jobType; public Worker(string jt) { this.jobType = jt; } public…
Isaac Pounder
  • 177
  • 1
  • 4
  • 14
3
votes
3 answers

Sanitize User Input in C# - Cleanest Way?

There's a gotcha when inserting img's dynamically via scripts. Take the following code to insert a image for a place: newPlace.find('.PlaceThumb').append('' + place.Name + '
John Shedletsky
  • 7,110
  • 12
  • 38
  • 63
3
votes
1 answer

PHP overloading return by reference, update value in array

I have a class for session handling that uses object overloading for __GET and __SET, I've been having issues with arrays and read to assign get by reference, such as &__GET The problem is I can't update the values. For example, let's say I have…
David
  • 499
  • 2
  • 8
  • 15
3
votes
1 answer

Inheritance and member-function templates overloading

I try to compile the following code with clang (version 3.0), but it gives me this error error: no matching member function for call to 'a' in the call __a.a<0>(). Then I try with g++ (version 4.2.1) and it compiles and works as expected (print out…
mattia.penati
  • 532
  • 5
  • 18
3
votes
2 answers

Overload resolution picks incompatible generic method instead of compatible base class method

I ran in an overloading resolution problem which I did not expect. Apparently the compiler rather resolves a call to the MyPrint method passing "Hello world" to the MyPrint(T : struct) in the derived class than to the MyPrint(string) defined in…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
3
votes
6 answers

Reasons for basic __get implementation

Other similar questions: Why I should use __get() and __set()-magic methods in php? When do/should I use __construct(), __get(), __set(), and __call() in PHP? First, I completely understand how to implement __get and __set methods in PHP and have…
Charles Sprayberry
  • 7,741
  • 3
  • 41
  • 50
3
votes
10 answers

Generics or just use overloads?

I have 3 classes, all share similar properties. 3 of the properties are named exactly the same across all 3 classes. Rather that write 3 methods (one for each class) is there some way I can utilise generics here? public static String…
user1017882
3
votes
2 answers

Working around overloading restriction (implementing a trait for several types)

I know it's not possible to overload methods which differ only in the return type. But I wonder if there are any smart strategies to deal efficiently with this situation: trait Reader[A] { def read(in: java.io.DataInput): A } trait B; trait C def…
0__
  • 66,707
  • 21
  • 171
  • 266
3
votes
1 answer

Overloaded c++ methods profiling using SystemTap

How can I differentiate between overloaded methods using SystemTap probes? E.g. class A { // ... void doFoo(); void doFoo(int a); // ... }; In a .stp file: probe process("foobar").function("A::doFoo").return { // do something } probe…
milton
  • 988
  • 6
  • 19
3
votes
2 answers

Method overriding in Ruby

I have code that looks like this: module A def b(a) a+1 end end class B include A end I would like to write a method in the class B that looks sort of like this class B def b(a) if a==2 # are you sure? same result as…
davorb
  • 613
  • 1
  • 9
  • 17
3
votes
3 answers

No lifting of scalar arguments to arrays in Fortran

Why is it that Fortran will promote a scalar expression to an array, in an expression, but not as an argument to a procedure? In particular, why did the standards body make this design decision? Is it solely because of ambiguity, should the…
user2023370
  • 10,488
  • 6
  • 50
  • 83
3
votes
3 answers

How do I fix "ambiguous overload" error when overloading operator<< (templated)?

I am trying to overload the << operator, but I get the following error: error: ambiguous overload for 'operator<<' in 'std::cout << "Test "' ..Followed by 5 billion other errors similar…
Joey
  • 41
  • 1
  • 2
  • 4
1 2 3
99
100