overloading

Why is this an "overloading ambiguity" in gcc?

Why is this an error : ie. arent long long and long double different types ? ../src/qry.cpp", line 5360: Error: Overloading ambiguity between "Row::updatePair(int, long long)" and "Row::updatePair(int, long double)". Calling code: . . pRow -> updatePair(924, 0.0); pRow -> updatePair(925, 0.0); . ...

Using all overloads of the base class

When a subclass overrides a baseclass's method, all of the baseclass's overloads are not available from the subclass. In order to use them there should be added a using BaseClass::Method; line in the subclass. Is there a quick way to inheirt the baseclass's overloads for ALL of the overridden methods? (not needing to explicitly specify ...

PHP __call vs method_exists

The Project I'm working on contains something like a wrapper for call_user_func(_array) which does some checks before execution. One of those checks is method_exists (In Case the supplied first argument is an instance of a class and the second is a method name) The other is_callable. The function will throw an exception if one of those c...

Differences between template specialization and overloading for functions?

So, I know that there is a difference between these two tidbits of code: template <typename T> T inc(const T& t) { return t + 1; } template <> int inc(const int& t) { return t + 1; } and template <typename T> T inc(const T& t) { return t + 1; } int inc(const int& t) { return t + 1; } I am confused as to what the f...

When does it make more sense to use the factory pattern rather than an overloaded constructor to instantiate an object?

In Karl Seguin's Foundations of Programming there is a small section on using the factory pattern. He closes the passage by stating "you can accomplish the same functionality with constructor overloading", but doesn't indicate when or why? So,when does it make more sense to use the factory pattern rather than an overloaded constructor ...

Should I duplicate tests for convenience overloads?

It's really common for me to make convenience overloads for methods. Here's an example of something I might do: public void Encode(string value) { Encode(value, DefaultEncoding); } public void Encode(string value, Encoding encoding) { // ... } I'm starting to pay more attention to unit testing, and testing methods like thi...

Abusing the comma operator in C++

I'm looking for an easy way to build an array of strings at compile time. For a test, I put together a class named Strings that has the following members: Strings(); Strings(const Strings& that); Strings(const char* s1); Strings& operator=(const char* s1); Strings& operator,(const char* s2); Using this, I can successfully compile co...

Difference between variable-length argument and function overloading

This C++ question seems to be pretty basic and general but still I want someone to answer. 1) What is the difference between a function with variable-length argument and an overloaded function? 2) Will we have problems if we have a function with variable-length argument and another same name function with similar arguments? ...

Why is the compiler not selecting my function-template overload in the following example?

Given the following function templates: #include <vector> #include <utility> struct Base { }; struct Derived : Base { }; // #1 template <typename T1, typename T2> void f(const T1& a, const T2& b) { }; // #2 template <typename T1, typename T2> void f(const std::vector<std::pair<T1, T2> >& v, Base* p) { }; Why is it that the followin...

Why is method overloading not defined for different return types?

In Scala, you can overload a method by having methods that share a common name, but which either have different arities or different parameter types. I was wondering why this wasn't also extended to the return type of a method? Consider the following code: class C { def m: Int = 42 def m: String = "forty two" } val c = new C val...

Java Overload method with inherited interface

Hi all, i'm trying to understand java behaviour. Using this interfaces : public interface IA {} public interface IB extends IA {} public class myClass implements IB {} I'm overloading a method like this : public void method(IA a); public void method(IB b); When calling method with the following object : IA a = new myClass(); met...

Overloading of GetEnumerator

Can't i overload GetEnumerator () like IEnumerator<T> IEnumerable<T>.GetEnumerator<T> ( T[] val1,T[] val2) { .... some code } ...

Overloading array insertion?

I'm processing a XML with minOccurs and maxOccurs set frequently to either 0, 1, or unbounded. I have a schema describing this cardinality, together with the specific data type. I'd like to construct a (Delphi) class which keeps track of the cardinality, together with an array whose dimensions are to be validated based on the minOccurs a...

Function/Method Overloading C++: Data type confusion?

Hi, I'm having some trouble overloading methods in C++. As an example of the problem, I have a class with a number of methods being overloaded, and each method having one parameter with a different data type. My question: is there a particular order in the class these methods should appear in, to make sure the correct method is called d...

Access to Perl's empty angle "<>" operator from an actual filehandle?

I like to use the nifty perl feature where reading from the empty angle operator <> magically gives your program UNIX filter semantics, but I'd like to be able to access this feature through an actual filehandle (or IO::Handle object, or similar), so that I can do things like pass it into subroutines and such. Is there any way to do this...

"Overloading" standard GORM CRUD methods

Wanna do the following: BootStrap { def init = {servletContext -> ........ MyDomainClass.metaClass.save = {-> delegate.extraSave() //////// how to call original save() here? } } ......... } P.S. MyDomainClass#extraSave is defined as public void extraSave(){.....} ...

C# Custom Events with Overloads

So I have a custom event like this: Work w = new worker() w.newStatus += new worker.status(addStatus); w.doWork(); void addStatus(string status) { MessageBox.Show(status); } and this: public event status newStatus; public delegate void status(string status); public void doWork() { ...

java: different return types when overloading

Hi, I have a class tree like this: master class abstract class Cell AvCell extends Cell FCell extends Cell i have an abstract method getValue() in Cell Is it posibble to make the method getValue() to return int for AvCell and String for FCell? Can i use generics for int String? Thanks! ...

Overloaded signification on msdn

I don't understand what does the overloaded term mean in the context of msdn library's page for MemoryStream Close method (or others like Dispose). See the page here. To me, overloaded points out the fact that you are providing a method with the same name but different signature than an existing one AND in the same class. In this case,...

Delphi/pascal: overloading a constructor with a different prototype

I'm trying to create a child class of TForm with a special constructor for certain cases, and a default constructor that will maintain compatibility with current code. This is the code I have now: interface TfrmEndoscopistSearch = class(TForm) public /// original constructor kept for compatibility constructor Create(AO...