Questions for polymorphism


3060

Rails 3.2 Rendering Associated Models in Same Form

i'm working through Hartl. Ive got to the microposts section in Chapter 10, but instead of microposts I have introduced Hotels, and now I want to add them to a separate address model, like in this
5517

Polymorphism for geometric forms

I am developing a small drawing application, with a little library of "complex" forms to be dragged and dropped.
5337

How to mimic polymorphism in classes with template methods (c++)?

in the problem i am facing i need something which works more or less like a polymorphic class, but which would allow for virtual template methods.
4576

How to get the integers 35 and 50 in the output of this program ?

I am really very new in C++ programming and its been only a month i started learning Object Oriented Programming and i was learning this program of inheritance and I am not getting the output i wan...
5840

Polymorphic factory / getInstance() in Java

I'm aiming to create a set of objects, each of which has a unique identifier. If an object already exists with that identifier, I want to use the existing object. Otherwise I want to create a new o...
8027

How should I cast for Java generic with multiple bounds?

Is it possible to cast an object in Java to a combined generic type?
8827

should new behavior be introduced via composition or some other means?

I chose to expose some new behavior using composition vs. injecting a new object into my consumers code OR making the consumer provide their own implementation of this new behavior. Did I make a bad
7314

How/when do I use a virtual destructor?

I'm currently writing a program with the following polymorphic hierarchy: Base: Multinumber. Derived: Pairs, Complex, Rational. Multinumber is a virtual class and is never instantiated.
6170

Mongoid complex ploymorphic relationship

I would like to set up a set of relationships that look something like the code below
7358

Convert derived class to base class

I'm trying to refresh my memory but can't find answers with Google.
428

Rails inheritance for classes of same behaviour but different attributes

I have been researching on the best approach for my problem which I originally had implemented as a single table inheritance but am deeply concerned about the scalability, as potentially will have
3890

Rails polymorphic association representing existing has_many models

I'd like to create a 'timeline' feature for an existing Card model. The Card already has_many Notes and has_many Attachments. I'd like to be able to:
8276

Send actual object type to overloaded function

So, please consider the following situation
7886

Multiple Inheritance/Polymorphism Homework

I have a homework assignment coming up that I am a bit confused on. The assignment basically states that we are to use Multiple Inheritance/Polymorphism to make 21 classes in a hierarchical manner. I
1501

Using inherited_resources for nested, polymorphic comments

I am new to using inherited resources and want to use it for
8319

How to get an object with certain type using C# Linq?

I have Generic list holding root objects means I have:
6248

How do you add images to an array?

I am stuck on a project because I have no clue how to store a picture into an array.
5534

Java snippet output not understood, probably related to polymorphism

I was wondering why this bit of Java yields 2, and not 3 :
5874

C++ - base implementation called through reference of derived?

Consider following code (minimal version):
3567

Weird polymorphism c++?

Anyone can explain this weird bit in this line of code to me?
1050

Extending a base class to a derived class

We have two classes BasicRace & AdvancedRace.
5972

How does boost::serialization Archive::register_type work?

boost::serialization is able to serialize my polymorphic objects of their most-derived class even if these objects are pointed by a reference/pointer to the base class. This without needing virtual
9974

Polymorphic methods not working on C# 4

I just stumbled over a very interesting problem. Giving the following code:
2036

Avoid RTTI when dealing with pairs of objects

I saw a few questions about avoiding RTTI, but mine seems to be a bit more specific. Here is an example case:
7439

Extensible ad hoc polymorphism? (C++11)

I need to implement a generic algorithm that can operate on a matrix regardless of its representation. It could be a C-style 2D array, a vector of vectors or an arbitrary user class (which does not
2398

How can I get a model class from a string?

I have a Model called Todo.rb which has an attribute called "asset" which is a string. The string contains the names of Models such as Call, Email, etc.
2998

Basic polymorphism/inheritance issues

I'm working with Java. I have done all of the research I could, but I could not find the answer to my question.There are certain parts of this code that I am not allowed to change and still fulfill...
6953

Use a children method c++

I have those objects:
9717

Method for getting polymorphic relationship table name in Rails. Meta-programming

I want to test if a Polymorphic child belongs to parent.
9971

Pre-written main function for each base class

Is there a sensible way to do the following:
719

Polymorphic MVC Views

So I am making a registration page in ASP.NET MVC and theres a list of fields which changes depending on a number of conditions (taken from a database).
4102

How to inherit a member function so that it always returns a reference to the derived instance?

I'm working on an iterator family, where all iterator classes X have X& operator++() {++x; return *this} in common, so it seems to be a good idea to place it in a common base class. Unfortunate...
3233

Methods of summary() function

I'm using summary() on output of mle(stats4) function, its output belongs to class mle. I would like to find out how summary() estimates standard deviation of coefficient returned by mle(stats4), b...
7218

Cleanly duplicate an instance of a baseclass or subclass in C++?

In the trivial example inheritance hierarchy:
9207

Copy object - keep polymorphism

The following code tries to copy an object and keep the original type.
4500

Haskell polymorphic calls without complete type knowledge

I'm studying Haskell since a little while, so I'm a newbie.
429

What's the difference between Polymorphism and Multiple Dispatch?

...or are they the same thing? I notice that each has its own Wikipedia entry: [1] [2], but I'm having trouble seeing how the concepts differ.
4603

Accessing Derived Singleton Instance Throws Compiler Error

I am trying to implement a Singleton base class in my Unity3d project. But attempting to access the instance of a Singleton raises compiler errors:
4765

java polymorphism

Consider the following code:
7822

Java Polymorphic processing: Incorrect output?

In the following class I am trying to print details of Employees in a payroll system.
1703

Is it really polymorphism?

Consider an interface called Shape which has a draw() method. Two classes Triangle and Circle implements the Shape interface and override the draw() method.
1254

Django polymorphism in view

I have the following model, using Django Polymorphic:
7240

Designing my program to avoid having to cast from base to derived class

Ok, I seem to be requiring forward casting from base to derived and I think it might be a design problem so I will explain what I’m doing and you can tell me what I need change.
5109

Passing Child Builders

I have a case where I have something like:
9840

Different Behavior Depending on the Data

Let's make it a simple example. Suppose I have a collection of Number objects, which can then be even or odd.
9193

Can child templates stored in a base class array, use an overloaded virtual function?

In hope to simplify a homework problem dealing with inheritance, I thought it might be better to use polymorphism to accomplish the task. It isn't required, but makes much more sense if possible. ...
409

boost::shared_ptr<> “explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete”

Can someone help me with the following error I get when trying to return an object polymorphically within a boost::smart_ptr:
5745

Serialize QVector of polymorphic pointers

I have an AbstractIndex defining the interface for its Items and the sorting and query algorithms. Further I have several concrete indizes like in the example below a FileIndex. Now I want to seria...
6519

Is is good practice to add a dummy method into a superclass so the subclass can override it?

I have a problem. It stems from calling a subclass method from a superclass, but with a twist. Any insight would be greatly appreciated.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.