overloading

method overloading and polymorphism

I'm writing a .NET web application in which administrators can customize the various data entry forms presented to their users. There are about half a dozen different field types that admins can create and customize (i.e. text, numeric, dropdown, file upload). All fields share a set of base attributes/behaviors (is the field required? ...

Linq to SQL SP parameters

I have a SP which I want to call from linq. The SP have 5 parameters but i only want to pass/need to 2 of them. how would I call the SP as when i go to add the parameters in code it wont build as it want all 5. ...

Does C# 4.0 and a combination of optional parameters and overloads give you a warning about ambiguity?

I've started reading Jon Skeet's early access version of his book, which contains sections on C# 4.0, and one thing struck me. Unfortunately I don't have Visual Studio 2010 available so I thought I'd just ask here instead and see if anyone knew the answer. If I have the following code, a mixture of existing code, and new code: public v...

How does the compiler determine which member functions mutate?

A comment to one of my posts interested me: Me too. I also give accessors/mutators the same name. I was wondering about this, because I have always used setBar(int bar) instead of a mutator named the same thing. I want to know: can the compiler determine based on a const identifier what mutates at runtime, or can it use the same fu...

Is it possible to make a property in javascript?

I want to make a custom Array object that recieves a number as index, and depending on the value of the index, it would return a computed value. For example: >>> var MyArray(2); >>> MyArray[2]; 4 >>> MyArray.2; 4 I know that for the showed example, I'm better of with a function, but I want to know if I can override the properties/ind...

Calling constructor overload when both overload have same signature

Consider the following class, class Foo { public Foo(int count) { /* .. */ } public Foo(int count) { /* .. */ } } Above code is invalid and won't compile. Now consider the following code, class Foo<T> { public Foo(int count) { /* .. */ } public Foo(T t) { /...

Is there a reason that C99 doesn't support function overloading?

Apparently (at least according to gcc -std=c99) C99 doesn't support function overloading. The reason for not supporting some new feature in C is usually backward compatibility, but in this case I can't think of a single case in which function overloading would break backward compatibility. What is the reasoning behind not including thi...

Overloads vs generic arguments

I have a question. In the framework, that was largely written before the generics came, you often see a function with lots of overloads to do something with different types. a) Parse(int data) Parse(long data) Parse(string data) ..etc That seems to be to be ok as it helps keeping code small for each method and so. On the other hand, ...

Overloading failUnlessEqual in unittest.TestCase

Hi, I want to overload failUnlessEqual in unittest.TestCase so I created a new TestCase class: import unittest class MyTestCase(unittest.TestCase): def failUnlessEqual(self, first, second, msg=None): if msg: msg += ' Expected: %r - Received %r' % (first, second) unittest.TestCase.failUnlessEqual(self, f...

Priority when choosing overloaded template functions in C++

I have the following problem: class Base { }; class Derived : public Base { }; class Different { }; class X { public: template <typename T> static const char *func(T *data) { // Do something generic... return "Generic"; } static const char *func(Base *data) { // Do something specific... return "Specific";...

How to use phpDoc with overloaded methods?

Let's say I have a PHP class called Color, it's constructor accepts various params. // hex color $myColor = new Color('#FF008C'); // rgb channels $myColor = new Color(253,15,82); // array of rgb channels $myColor = new Color(array(253,15,82)); // X11 color name $myColor = new Color('lightGreen'); My question is: How should I use p...

overloading on basis of return type only

I have a situation where i want to return List<> from this function public DataTable GetSubCategoriesBySubCatID(Guid SubCategoryID) So what i want is public List<SubCategories> GetSubCategoriesBySubCatID(Guid SubCategoryID) I know overloading is not supported on the basis of return type only,I just donot want to duplicate same code...

Implementing std::list item read/write events.

I'm new to c++ but have set my mind on a specific task that needs me to enable adding a specific chunk of code to be execute whenever any list item is attempted to be changed or read. The resulting list should behave and look as much as as possible to std::list except for this small exception that would enable me to execute a specific t...

Overloading LINQ's Add method for validation

I have an Email object and am attempting to validate the number of attachments that are in its List<Attachment> property. The trick is that we consume the Send() method across a WCF service. It's easy to validate it server side, but I want to validate it client side first. I have generated a library that others are supposed to use in ...

How do I get intellisense(code insight) features like of Jcreator in an IDE of linux platform ?

I previously programmed a lot in JCreator, but since I moved to ubuntu. I miss my Jcreator more than anything. Beside Eclipse or Netbeans, are there some lightweight software that does my task. Tried already gedit, jedit, scite, geany etc. with APIs plugins. But I can't find anything like Jcreator ? I just have 256 MB SDRAM to spare in ...

Overload Baseform

How do i use overload in C# I have a sample codes that goes like this Namespace Test Partial Class TestAccess Inherits BaseForm Dim db As New database Dim share As New ShareMethod Protected Overloads Overrides Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load MyBase.Page_Load(...

C# params keyword with two parameters of the same type

I just encountered something with C# today that I hadn't thought of before. I have two methods in my class, one an overload of the other. They are declared like so: 1) public void RequirePermissions(params string[] permissions)... 2) public void RequirePermissions(string message, params string[] permissions)... In my code, I tried to ...

What's going on with overriding and overloading here in C++?

This doesn't work: class Foo { public: virtual int A(int); virtual int A(int,int); }; class Bar : public Foo { public: virtual int A(int); }; Bar b; int main() { b.A(0,0); } It seems that by overriding Foo::A(int) with Bar::A(int) I have somehow hidden Foo::A(int,int). If I add a Bar::A(int,int) things work. Does any...

Can I overload Perl's =? (And a problem while use Tie)

I choose to use tie and find this: package Galaxy::IO::INI; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = {']' => []}; # ini section can never be ']' tie %{$self},'INIHash'; return bless $self, $class; } package INIHash; use Carp; require Tie::Hash; @INIHash::ISA = qw(Tie::StdH...

C++ override/overload problem

I'm facing a problem in C++ : #include <iostream> class A { protected: void some_func(const unsigned int& param1) { std::cout << "A::some_func(" << param1 << ")" << std::endl; } public: virtual ~A() {} virtual void some_func(const unsigned int& param1, const char*) { some_func(param1); } }; class B : public A { p...