overloading

Does function overloading work in C?

Possible Duplicates: function overloading in C Does C support overloading ? Can anyone explain if function overloading work in C? I tried this and it didn't work: #include <stdio.h> int f(int val) { printf("f int\n"); return 5; } int f(char *val) { printf("f char *\n"); return 6; } int main() { f(5);...

[c++] Problem with passing by reference

Can I overload a function which takes either a reference or variable name? For example when I try to do this: void function(double a); void function(double &a); I would like the caller of this function to be able to do: double a = 2.5; function(a); // should call function(double &a) function(2.3); // should call function(double a) ...

c++: set<customClasS* how to overload operator<(const customClass&*...)?!

Good Evening (depending on where u are right now). I am a little confused with the stl stuff for sorted sets... I want to store pointers of a custom class in my set and I want them to be sorted by my own criterion and not just the pointer size. Anyone has an idea how to do this? Since it is impossible to do it like operator<(const foo ...

Should i definitely have a constructor in a derived class?

My problem is like this. I have a XMLUtility class public class XmlUtility { protected string FilePath; protected string XMLFileName; protected XmlDocument SettingsFile; public XmlUtility(string inFilePath, string inXMLFileName) { FilePath = inFilePath; XMLFil...

Do I need to define `operator==` to use my class with standard containers?

I'd like clarification on the C++ standard, specifically where it says (my interpretation) in section 20.1.3 that "for class T and an instance of class T called x, T(x) must be equivalent to x" for the class to work with standard containers. I couldn't find a definition of 'equivalent'. Does this mean that I have to define operator== a...

What is this at the end of function ,...) in c++

Possible Duplicate: In a C function declaration, what does as the last parameter do? What does this mean ,...); it is written at the end of a function in a code i am debuging. like this void abc( int a, int b, ...); ...

Why does Scala type inference fail here?

I have this class in Scala: object Util { class Tapper[A](tapMe: A) { def tap(f: A => Unit): A = { f(tapMe) tapMe } def tap(fs: (A => Unit)*): A = { fs.foreach(_(tapMe)) tapMe } } implicit def tapper[A](toTap: A): Tapper[A] = new Tapper(toTap) } Now, "aaa".tap(_.trim) doesn't compile,...

Can I overload variables in Java?

I'm writing a class to represent a matrix. I want it to look something like this: public class matrix { private int[][] matrix; private double[][] matrix; //And so on and so forth so that the user can enter any primitive type and //get a matrix of it } Is this legal code, or would I have to have different variable name...

error: ambiguous overload for 'operator/'

Hello, I am new to c, and the following is giving me some grief: int i,j,ll,k; double ddim,ddip,ddjm,ddjp,ddlm,ddlp; for(i=1; i<(mx-1); i++){ for(j=1; j<(my-1); j++){ for(ll=1; ll<(mz-1); ll++){ ddim=0.5*k ddip=0.5*k ddjm=0.5*k ddjp=0.5*k ddlm=0.5*k ddlp=0.5*k Wijl(i,j,ll) = ((1.0/h_x)*(ddip) \ ((1.0/h_x)*(ddim)) \ ...

Why does Wikipedia say "Polymorphism is not the same as method overloading or method overriding."

I have looked around and could not find any similar question. Here is the paragraph I got from Wikipedia: Polymorphism is not the same as method overloading or method overriding. Polymorphism is only concerned with the application of specific implementations to an interface or a more generic base class. Method overloading refers to me...

What is the use/advantage of function overloading?

What is the use/advantage of function overloading? ...

How can I resolve this address of overloaded member function issue?

It's hackish, I know, but I recently needed to implement a stream class which would act mostly like a standard stream, but which would detect the std::endl manipulator and special-case it's behaviour. My first attempt at a particular method implementation was... mystream& mystream::operator<< (std::basic_ostream<char>& (*p) (std::basic_...

Alternative To A Series Of Overloaded Methods

I have a helper class that does a simple but repetitive process on a List of entities. For simplicity, it's like this... public static List<MyType> DoSomethingSimple(List<MyType> myTypes) { return myTypes.Where(myType => myType.SomeProperty.Equals(2)).ToList(); } I now need to add support for another type, but everything is identi...

java: multiple constructors

I'm having some trouble using multiple constructors in java. what I want to do is something like this: public class MyClass { // first constructor public MyClass(arg1, arg2, arg3) { // do some construction } // second constructor public MyClass(arg1) { // do some stuff to calculate arg2 and arg3 this(arg1, arg2, ar...

When should we use method overloading vs method with different naming

Sometimes, I felt method overloading may create confusion. class a { public: void copy(float f); void copy(double d); }; a me; me.copy(1.2); // Not obvious at the first sight on which version we are calling. A workaround on this is. class a { public: void copyFloat(float f); void copyDouble(double d); }; How...

.Net compact framework: inherit from DataGridTextBoxColumn, GetColumnValueAtRow is missing

The DataGrid in the .net compact framework (I'm using v3.5) is a bit limited. I try to display a bool-value with app-defined texts like "on/off" or translations of "true/false". I've created a class DataGridBoolColumn which inherits from DataGridTextBoxColumn and there I override the Paint-method. But I've problems with retrieving the cu...

What's the meaning of this C++ struct?

Hi, I got a simple C++ struct as follows: // Functor for peak to decreasing intensity sorting struct cmp_decr_int2 { bool operator() (peak2 a, peak2 b) { return a.int2 > b.int2; } }; is there an overload of the operator in this sample? ...

C++ methods overload in python

Hi, suppose a C++ class has several constructors which are overloaded according the number and type and sequences of their respective parameters, for example, constructor(int x, int y) and constructor(float x, float y, float z), I think these two are overloaded methods, which one to use depends on the parameters, right? So then in python...

Templated << friend not working when in interrelationship with other templated union types.

While working on my basic vector library, I've been trying to use a nice syntax for swizzle-based printing. The problem occurs when attempting to print a swizzle of a different dimension than the vector in question. In GCC 4.0, I originally had the friend << overloaded functions (with a body, even though it duplicated code) for every dim...

C# rules of function overloading

What are the rules regarding function Overloading? I have the following code: public T genericFunc<T>() where T : Component, new() { T result = new T(); overloadedFunction( result ); } private overloadedFunction ( Component c ) // catch all function private overloadedFunction ( DerivedFromComponent dfc) // specific function ...