overloading

Overloading/specializing STL algorithms for non-local containers (database back end).

What I want to do is, in a separate namespace, define my own sort(), copy(), etc implementations that work with database tables/views/etc containers instead of in-memory std containers. If I define my own sort() that accepts my custom forward iterator, how does the compiler resolve that? Or, what do I need to do so that it will resolve...

C++ overloading conversion operator for custom type to std::string

Hi, I hope someone might be able to answer why the following doesn't work. Bear with me though, I am still very much a noob... I just cannot get to the bottom of why the following using namespace std; #include <string> #include <iostream> class testClass { public: operator char* () {return (char*)"hi";}; operator int () {return 77;}...

: this() As a constructor

I'm trying to get a better understanding of general practice... specifically deriving this() in a constructor. I understand that its less code, but I consider it less readable. Is it common/good practice to do it this way? Or is it better to write a second constructor that handles it specifically? public SomeOtherStuff(string rabble)...

Advice on http-method overloading in REST

Hi all, I've used a regular expression in @Path to achieve overloading and at first I thought it was really neat, but overloading methods is usually not good practice. Does the same apply to RESTful web services? Is there a better way to achieve this using JAX-RS? So I can now call my getProject REST service by /project/ProjectNumber10...

Overloading List Comprehension Behavior?

I'm tasked with creating a model of a cage of hardware. Each cage contains N slots, each slot may or may not contain a card. I would like to model the cage using a list. Each list index would correspond to the slot number. cards[0].name="Card 0", etc. This would allow my users to query the model via simple list comprehensions. For e...

Method overloading - good or bad design?

I like to overload methods to support more and more default cases. What is the performance impact of method overloading? From your experience, is it advisable to overload methods? What is the limit? What are the workarounds? ...

C++/CLI: Is overloading on return type only possible ?

If I understand well, in C#, it is possible to do public class X : ICloneable { public X Clone() { ... } object ICloneable.Clone() { return Clone(); } // This calls the above } according to this thread. This kind of overloading is forbidden in C++, since it only depends on the return type. Now, I would like to do this exact t...

Operator << overload in c++

#include <iostream> #include <fstream> class obj { public: int i; friend ostream& operator<<(ostream& stream, obj o); } void main() { obj o; ofstream fout("data.txt"); fout<<o; fout.close(); } This is the my code, am getting error. error : ostream : ambiguous symbol. any one can help me. ...

Method overloading standard protocol?

If you add a third signature for a method, do you make the second and third variations directly call the first (the implemented variation), or do you make the third call the second and the second call the first. It would seem to me that the extra method call would be overhead you could live without, so you'd want all the methods to call...

Java Annotation Overloading?

In my project, I have defined the an annotation similar to the following: (Omitting @Retention, @Target for brevity) public @interface DecaysTo { String[] value(); } Since originally writing it, our needs have changed and I have now defined an enum that I want to be able to use in place of the string: public enum Particle { E...

Overloading best practice

I have two static methods that I want to use for error handling. One of which passes the exception object and the other is just used if needing to report an error which would be a text based message (string errorMessage). The code within the two methods is pretty much the same with the exception of how the message is build up and sent ...

overloading dereference operator

hi, I am new to C++ and i have a question on overloading dereference operator. I am building a in memory object store which is to be used by the applications. The data store is mapped in to the applications memory space and applications can directly read/modify the object using dereference operator . I plan to provide an interface desc...

Is function overloading possible in Objective C?

Is function overloading possible in Objective C ? Well,Most of the programmers says no, But it looks like possible, for example: -(int)AddMethod:(int)X :(int)Y { return X + Y; } -(int)AddMethod:(int)X { return X; } to call 1st one write [self AddMethod :3]; to call last one write [self AddMethod: 3 :4]; ...

Documenting overloaded methods with the same XML comments

Say I have this constructor: /// <summary> /// Example comment. /// </summary> public SftpConnection(string host, string username, string password, int port) {...} which has these overloads: public SftpConnection(string host, string username, string password) : this(host, username, password, 22) { } public SftpConnection(s...

overloading F# active patterns

I am fairly new to F# and active patterns, and I ran across an anomoly that I can't explain. module Eval = let (|Bet|Pass|) (test:BetChoice) = match test with | BetChoice.Bet -> Bet | BetChoice.Pass -> Pass let (|NoBet|Bet|Pass|) (test:Nullable<BetChoice>) : Choice<unit, unit, unit> = match test.HasValue with ...

Generic overload resolution

I have the following scenario: class Foo { } class Foo<T> : Foo { } And then two methods void DoStuff(Foo foo) { DoStuffImpl(foo); } void DoStuffImpl(Foo foo) { Console.WriteLine("A"); } void DoStuffImpl<T>(Foo<T> foo) { Console.WriteLine("B"); } void Main() { DoStuff(new Foo<int>()); // prints A } ...

Functions with const arguments and Overloading

Was tryin out the stackeroverflow qn so it got me thinking why not overload the the function and I came up with a slightly different code but it says the function cannot be overloaded. My question is why? or is there a another way? #include <iostream> using std::cout; class Test { public: Test(){ } int foo...

functions with const arguments Overloading ( Follow up)

This is a follow up of the Previous Question It got really complicated so I am starting a new thread to make my point clearer.( Didnt want to delete the previous thread because the other guys who gave valuable feedback dont not loose the reputation points they gained) Updated Code: (Complies and Works) #include <iostream> using std...

Friend functions not recognized

I have the following class with a couple friend functions: class Teleport { public: Teleport(); ~Teleport(); void display(); Location teleportFrom(int direction); friend bool overlap(Wall * wall, Teleport * teleport); friend bool overlap(Location location); friend bool overlap(Wall * wall); friend bool o...

Subclass/Superclass - If a subclass is cast as its superclass, is there a way to use the overloaded properties of the subclass?

Sorry if the title isn't very clear. This is a VB.NET (2010) question I have a superclass called "Device" which has a number of subclasses that inherit it. Some of those subclasses also have subclasses. In particular, I have a class called "TwinCatIntegerDevice" which inherits "TwinCatDevice" which inherits "Device." The relevant pa...