overloading

Can I have conditional construction of classes when using IoC.Resolve ?

I have a service class which has overloaded constructors. One constructor has 5 parameters and the other has 4. Before I call, var service = IoC.Resolve<IService>(); I want to do a test and based on the result of this test, resolve service using a specific constructor. In other words, bool testPassed = CheckCertainConditio...

Overloading properties in C#

Ok, I know that property overloading is not supported in C# - most of the references explain it by citing the single-method-different-returntype problem. However, what about setters? I'd like to directly assign a value as either a string or object, but only return as a string. Like this: public string FieldIdList { ge...

Why in C# 3.0, when we overload constructor of a specified class, we should write default constructor in class body?

Hi Why in C# 3.0, when we overload constructor of a specified class, we should write default constructor in class body? As far as I know, It was no need to do so. class Test { public int ID {get; private set;} public int Name {get; private set;} public Test() { } public Test(int id, int name) ...

Is this a well known design pattern? What is its name?

I have seen this often in code, but when I speak of it I don't know the name for such 'pattern' I have a method with 2 arguments that calls an overloaded method that has 3 arguments and intentionally sets the 3rd one to empty string. public void DoWork(string name, string phoneNumber) { DoWork(name, phoneNumber, string.Empty) } pr...

Using php's magic function inside another function does not work

I want to use magic function __set() and __get() for storing SQL data inside a php5 class and I get some strange issue using them inside a function: Works: if (!isset($this->sPrimaryKey) || !isset($this->sTable)) return false; $id = $this->{$this->sPrimaryKey}; if (empty($id)) return false; echo 'yaay!'; Does not work: if (!isset(...

Overload Anonymous Functions

Still wrapping my head around Delegates and I'm curious: Is it possible to overload anonymous functions? Such that: delegate void Output(string x, int y); Supports: Output show = (x, y) => Console.WriteLine("{0}: {1}", x.ToString(), y.ToString()); And: delegate void Output(string x, string y); Allowing: show( "ABC", "EFG" ); ...

Why overload true and false instead of defining bool operator?

I've been reading about overloading true and false in C#, and I think I understand the basic difference between this and defining a bool operator. The example I see around is something like: public static bool operator true(Foo foo) { return (foo.PropA > 0); } public static bool operator false(Foo foo) { return (foo.PropA <= 0); } ...

Haskell: Problems with overloading: Interpreter can´t tell which + to use

Hi, I want to make functions Double -> Double an instance of the Num typeclass. I want to define the sum of two functions as sum of their images. So I wrote instance Num Function where f + g = (\ x -> (f x) + (g x)) Here the compiler complains he can´t tell whether I´m using Prelude.+ or Module.+ in the lambda expression. So I impor...

C++ function overloading and dynamic binding compile problem

Possible Duplicates: C++ method only visible when object cast to base class?! Why does an overridden function in the derived class hide other overloads of the base class? #include <iostream> using namespace std; class A { public: virtual void foo(void) const { cout << "A::foo(void)" << endl; } virtual void foo(int ...

SQL Server tuning tools for finding overload

I use SQL Server as a DBMS for my very big corporate DB (with different financial data). And some times my system go down. I don't understand why. What programs/tools I can use for finding process/program/thread, that overload my SQL Server? Thanks for all answers! ...

Function template overloading: link error

I'm trying to overload a "display" method as follows: template <typename T> void imShow(T* img, int ImgW, int ImgH); template <typename T1, typename T2> void imShow(T1* img1, T2* img2, int ImgW, int ImgH); I am then calling the template with unsigned char* im1 and char* im2: imShow(im1, im2, ImgW, ImgH); This compiles fine, but i g...

Partial overriding in Java (or dynamic overriding while overloading)

If I have a parent-child that defines some method .foo() like this: class Parent { public void foo(Parent arg) { System.out.println("foo in Function"); } } class Child extends Parent { public void foo(Child arg) { System.out.println("foo in ChildFunction"); } } When I called them like this: Child f = new Child();...

Why this function overloading is not working?

class CConfFile { public: CConfFile(const std::string &FileName); ~CConfFile(); ... std::string GetString(const std::string &Section, const std::string &Key); void GetString(const std::string &Section, const std::string &Key, char *Buffer, unsigned int BufferSize); ... } string CConfFi...

How is <tgmath.h> implemented?

C doesn't have (to the best of my knowledge) overloading or templates, right? So how can a set of type-agnostic functions with the same name exist in plain ol' C? The usual compile-time trickery would involve a whole bunch of macros, wouldn't it? ...

Operator issues with cout

I have a simple package class which is overloaded so I can output package data simply with cout << packagename. I also have two data types, name which is a string and shipping cost with a double. protected: string name; string address; double weight; double shippingcost; ostream &operator<<( ostream &output, const Pa...

Overloading with same parameter signature

In C#, is it possible to have same parameters yet override each other(they are different in the return types) public override Stocks[] Search(string Field,string Param){ //some code} public override Stocks Search(string Field, string Param){//some code} C# returns compilation error ...

Why can't I assign a scalar value to a class using shorthand, but instead declare it first, then set its value?

I am writing a UTF-8 library for C++ as an exercise as this is my first real-world C++ code. So far, I've implemented concatenation, character indexing, parsing and encoding UTF-8 in a class called "ustring". It looks like it's working, but two seemingly equivalent ways of declaring a new ustring behave differently. The first way: ustri...

Game Key Events: Event or Method Overload?

If you were going to develop a game in say, Ruby, and you were provided with a game framework, would you rather act on key up/down events by overloading a method on the main window like so: class MyGameWindow < Framework::GameWindow def button_down(id) case id when UpArrow do_something ...

+= Overloading in C++ problem.

I am trying to overload the += operator for my rational number class, but I don't believe that it's working because I always end up with the same result: RationalNumber RationalNumber::operator+=(const RationalNumber &rhs){ int den = denominator * rhs.denominator; int a = numerator * rhs.denominator; int b = rhs.numerator * d...

Detect if class has overloaded function fails on Comeau compiler

Hi Everyone, I'm trying to use SFINAE to detect if a class has an overloaded member function that takes a certain type. The code I have seems to work correctly in Visual Studio and GCC, but does not compile using the Comeau online compiler. Here is the code I'm using: #include <stdio.h> //Comeau doesnt' have boost, so define our own...