I'm trying to define a class (or set of classes which implement the same interface) that will behave as a loosely typed object (like JavaScript). They can hold any sort of data and operations on them depend on the underlying type.
I have it working in three different ways but none seem ideal. These test versions only allow strings and i...
Can anybody explain in detail the reason the overloaded method print(Parent parent) is invoked when working with Child instance in my test piece of code?
Any pecularities of virtual methods or methods overloading/resolution in Java involved here?
Any direct reference to Java Lang Spec?
Which term describes this behaviour?
Thanks a lot.
...
I was bored and came up with such hack (pseudocode):
1 struct proxy {
2 operator int(); // int function
3 operator double(); // double function
4 proxy(arguments);
5 arguments &arguments_;
6 };
7
8 proxy function(arguments &args) {
9 return proxy(args);
10 }
11 int v = function(...);
12 double u = function(....
Since curried functions cannot be overloaded and modules cannot have members, does this mean there is no way to have an overloaded function in a module? The answer seems obvious, but I want to make sure there's not something I'm overlooking.
...
As we can see, send method is not overloaded.
from socket import socket
class PolySocket(socket):
def __init__(self,*p):
print "PolySocket init"
socket.__init__(self,*p)
def sendall(self,*p):
print "PolySocket sendall"
return socket.sendall(self,*p)
def send(self,*p):
print "PolySo...
What is the difference between these two ways of overloading the != operator below. Which is consider better?
Class Test
{
...//
private:
int iTest
public:
BOOL operator==(const &Test test) const;
BOOL operator!=(const &Test test) const;
}
BOOL operator==(const &Test test) const
{
return (iTest == test.iTest);
} ...
Hey guys.
I'm trying to write my own C++ String class for educational and need purposes.
The first thing is that I don't know that much about operators and that's why I want to learn them.
I started writing my class but when I run it it blocks the program but does not do any crash.
Take a look at the following code please before reading ...
if i have two classes x and y, both extend class w. and x implementing interface z. if i have methods doSomething(w object) and doSomething(x object), what would happen if i call doSomething(x)?
edit:
im implementing this on java, more specifically on android.
im asking this because some classes which implement a specific interface most...
Hello, I just hit a situation where a method dispatch was ambiguous and wondered if anyone could explain on what basis the compiler (.NET 4.0.30319) chooses what overload to call
interface IfaceA
{
}
interface IfaceB<T>
{
void Add(IfaceA a);
T Add(T t);
}
class ConcreteA : IfaceA
{
}
class abstract BaseClassB<T> : IfaceB<T>...
Does anyone have a very simple example of how to overload the compound assignment operator in C#?
...
I am drawing some graphs using the Point object and I want to set it so
it supports doubles as its parameters. I am working on Visual C#, WindowsConsoleApplication
Thank you.
...
I need to confirm something before I go accuse someone of ... well I'd rather not say.
The problem:
We allow users to upload images and embed them within text on our site. In the past we allowed users to hotlink to our images as well, but due to server load we unfortunately had to stop this.
Current "solution":
The method the program...
I tried to implement IEnumerator< Status > but got errors about two different Properties not being implemented.
'DataReader' does not implement
interface member
'System.Collections.Generic.IEnumerator.Current'
'DataReader' does not implement
interface member
'System.Collections.IEnumerator.Current'
The solution that wo...
I have few problems with my basic and would be thankful if someone can clear this.
1: What does it mean when I say base *b
= new derived; Why would one go for this? We very well separately can
create objects for class base and
class derived and then call the
functions accordingly. I know that
this base *b = new deriv...
Why the following code works?
typedef char (&yes)[1];
typedef char (&no)[2];
template <typename B, typename D>
struct Host
{
operator B*() const;
operator D*();
};
template <typename B, typename D>
struct is_base_of
{
template <typename T>
static yes check(D*, T);
static no check(B*, int);
static const bool value = sizeo...
I have implemented the following interface:
template <typename T>
class Variable
{
public:
Variable (T v) : m_value (v) {}
virtual void Callback () = 0;
private:
T m_value;
};
A proper derived class would be defined like this:
class Derived : public Variable<int>
{
public:
Derived (int v) : Variable<int> (v) {}
void Callbac...
I do have three dlls.
a.dll - released many years ago
b.dll - released not so many years
c.dll - released shortly
Each one contains the same function - unfortunatelly with different parameters.
so I do have the following Methods
aMethod(param1)
aMethod(param1, param2)
aMethod(param1, param2, param3)
My Task is to make a new dll (o...
Hi there,
been creating a few wcf methods and i have a mehtod called IsValidLogin ... there various versions, 1 takes 2 strings, 1 takes an object etc.
Of course in WCF you can't overload methods can anyone suggest the best way to name these methods..
I was thinking of IsValidLogin1, IsValidLogin2??
But i am open to any suggestions
...
Hi,
Is it possible to overload the array/dict access operators in VB.net? For example, you can state something like:
Dim mydict As New Hashtable()
mydict.add("Cool guy", "Overloading is dangerous!")
mydict("Cool guy") = "Overloading is cool!"
And that works just fine. But what I would like to do is be able to say:
mydict("Cool guy")...
Why C++ compiler gives this error? Why i can access lol() from B, but can not access rofl() [without parameters]. Where is the catch?
class A
{
public:
void lol(void) {}
void rofl(void) { return rofl(0);}
virtual void rofl(int x) {}
};
class B : public A
{
public:
virtual void rofl(int x) {}
};
int _tmain(int argc, _TCHAR*...