I have a superclass that handles car decal information. I have a subclass that handles specific decal information for a transaction. I have a special override in the transaction decal that is used to check for certain things before a decal # can be set. The problem I'm having is that sometimes I need to grab information about a generi...
I am working through a bug. In recreating the bug for the following sample I was able to determine why the problem is happening. But I am stuck for a better solution. So given the following program:
public interface IFoo<T> {
T OutputType(T param);
}
class Foo : IFoo<Foo> {
public virtual Foo OutputType(Foo param) {
Con...
Hi,
I have an issue with Ruby on Rails.
I have several model classes that inherit from the same class in order to have some generic behaviour.
The parent class is called CachedElement.
One of the child is called Outcome.
I want an other model, called Flow to belong to any child of CachedElement.
Hence Flow has a polymorphic attributes...
Question:
Why is my C++ swigged object losing its type when passed to a Java callback function?
Setup:
I've taken the Swig Java example for doing callbacks and added an object to be passed to the callback run(Parent p). The callback works as expected but when I pass a Child object the Java seems to lose its type and think its of type Pa...
I am trying to figure out the exact meaning of the words Covariance and Contravariance from several articles online and questions on StackOverflow, and from what I can understand, it's only another word for polymorphism.
Am I correct with the above statement? Or have I got it wrong ?
...
What is a common practice for the storage of a list of base class pointers each of which can describe a polymorphic derived class?
To elaborate and in the interest of a simple example lets assume that I have a set of classes with the following goals:
An abstract base class whose purpose is to enforce a common functionality on its deri...
I have a class C. Class E extends it.
E e = new E();
C c = new C();
Why is
e = (E) c;
Upon further review: though numeric conversions have the same syntax as casting objects, some confusion arose. At any event, the above does not give a compilation, but rather a runtime error - so a class can be casted to subclass in some instances...
Suppose Y is a derived class from class X and X declares foo to be virtual. Suppose y is of type (Y*). Then ((X*)y)->foo() will execute the Y version of foo(), but ((X)*y).foo() will execute the X version. Can you tell me why polymorphism does not apply in the dereferenced case? I would expect either syntax would yield the Y version of f...
I am using boost::any to store pointers and was wondering if there was
a way to extract a polymorphic data type.
Here is a simple example of what ideally I'd like to do, but currently doesn't work.
struct A {};
struct B : A {};
int main() {
boost::any a;
a = new B();
boost::any_cast< A* >(a);
}
This fails because a is ...
I am using the acts as taggable on steroids plugin and my web app has 4 models:
Category
Entry - acts as taggable and contains the following using single table inheritance
Story
Topic
Category has two important fields:
tags:string - A list of tags associated with this category
primary_tag:string - A single tag that gets assigned ...
Hi!
I have 4 base classes:
class A { virtual SomeMethod () { <code> } }
class A<T> { virtual SomeMethod () { <code> } }
class B { virtual SomeMethod () { <code> } }
class B<T2> { virtual SomeMethod () { <code> } }
Now, i have 4 implementations (each implementation is derived from the corresponding base type).
class Aa : A { overrid...
In other words, given a base class shape and a derived class rectangle:
class shape
{
public:
enum shapeType {LINE, RECTANGLE};
shape(shapeType type);
shape(const shape &shp);
}
class rectangle : public shape
{
public:
rectangle();
rectangle(const rectangle &rec);
}
I'd like to know if I could create an instance of rectangl...
Hello Group,
We have a sub-project 'commonUtils' that has many generic code-snippets used across the parent project.
One such interesting stuff i saw was :-
/*********************************************************************
If T is polymorphic, the compiler is required to evaluate the typeid
stuff at runtime, and answer will be tr...
In situations where two interfaces apply to an object, and there are two overloaded methods that differ only by distinguishing between those interfaces, which method gets called?
In code.
interface Foo {}
interface Bar {}
class Jaz implements Foo, Bar {}
void DoSomething(Foo theObject)
{
System.out.println("Foo");
}
void DoSomet...
I'm working on a multithreaded application, and I want to debug it using GDB.
Problem is, one of my threads keeps dying with the message:
pure virtual method called
terminate called without an active exception
Abort
I know the cause of that message, but I have no idea where in my thread it occurs. A backtrace would really be helpful....
What are the 'costs' involved in calling an empty PHP function? The main purpose is for a CMS to trigger included module events at various points in its lifespan to handle things like security, access permissions, post processing, timing, http(s) and the like. Since there can be over a dozen modules called dozens of times each the tota...
In my application, I have two classes: a logger that actually logs to the database and a dummy logger that does nothing (used when logging is disabled). Here is the entire DummyLog class:
class DummyLog(object):
def insert_master_log(self, spec_name, file_name, data_source,
environment_name):
pass...
C++ does not allow polymorphism for methods based on their return type. However, when overloading an operator this seems possible.
Does anyone know why? I thought operators are handled like methods internally.
Edit: Here's an example:
struct func {
operator string() { return "1";}
operator int() { return 2; }
};
int main( ) {...
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know, that is bad). The web service is being consumed by a .NET based client.
Before we had Axis1, and when custom objects were passed between the client and the server, the client and the server code had to do their own serialization and de-serialization.
When...
class Base
{
public:
virtual void foo()
{}
};
class Derived: public Base
{
public:
virtual void foo()
{}
};
int main()
{
Base *pBase = NULL;
Base objBase;
Derived objDerived;
pBase = &objDerived;
pBase->foo();
/*Here Derived class foo will be called, but i want this to call
a base clas...