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...
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...
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)
...
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...
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(...
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" );
...
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);
}
...
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...
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 ...
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!
...
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...
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();...
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...
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?
...
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...
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
...
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...
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
...
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...
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...