polymorphism Questions
3
Solved
I know that open closed principle mean open for extension and closed for modification. Consider an example as follows
public class Vehicle{
public void service(){
//vehicle servicing code
}
}
...
Elyot asked 7/4, 2015 at 17:54
2
Solved
I have a polymorphic value type implemented like so:
class ShapeValue {
public:
template<class T>
ShapeValue(const T& value) {
obj = make_unique<holder<T>>(value);
}
//...
Peashooter asked 23/7, 2019 at 16:49
4
Solved
I have problem with subclassing and using methods.
I create an instance of class B and store it as a pointer to A. But when I use the pointer to call the overloaded method, the output is "A" not "...
Rodgers asked 18/2, 2013 at 15:8
2
Solved
I have a base class in which I have a pure virtual function and with this function, I want to override it in other derived classes (in some of those with a different number of parameters if possibl...
Harmonyharmotome asked 24/8, 2020 at 17:25
4
Solved
I understand the concept of Polymorphic and Metamorphic code but I recently read the Wikipedia page on both (for what ever reason I hadn't done this previously!). Now I really want to have a go at ...
Recall asked 11/4, 2012 at 20:14
3
Solved
When I have a function in Scala:
def toString[T: Show](xs: T*): String = paths.map(_.show).mkString
And the following type class instances in scope:
implicit val showA: Show[MyTypeA]
implicit val ...
Tc asked 12/8, 2020 at 16:3
1
Let's say, I have an Event model, which has more participants of various models (Player, Coach, Admin) through polymorphic relation and a pivot table (EventParticipant), which also contains a boole...
Discommodity asked 30/9, 2018 at 16:8
1
Solved
I am learning some polymorphism.
The wiki page for rust addresses trait is a method to achieve ad hoc polymorphism, and the page for ad hoc polymorphism says function overloading is an example of a...
Sardinian asked 2/8, 2020 at 22:30
3
Solved
I understand why this is happening, but I'm stuck trying to resolve it...here is what my code is doing when the error is generated (thus, leading to a crash) when my program exits...
pure virtual ...
Alleviate asked 22/5, 2012 at 17:49
4
I am having a issue with an Eloquent morphOne relationship where it is creating new entries rather than updating the one that already exists.
Basically I have a number of models (for example, let'...
Roveover asked 11/7, 2014 at 9:42
4
Solved
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 ac...
Agma asked 12/7, 2009 at 6:41
4
Solved
I'm new to Python... and coming from a mostly Java background, if that accounts for anything.
I'm trying to understand polymorphism in Python. Maybe the problem is that I'm expecting the concepts ...
Conventionalism asked 14/5, 2010 at 16:23
7
Solved
class GrandParent
{
public virtual void Foo() { ... }
}
class Parent : GrandParent
{
public override void Foo()
{
base.Foo();
//Do additional work
}
}
class Child : Parent
{
public overri...
Hydric asked 2/8, 2011 at 14:19
6
I know that downcasting is basically casting parent class pointer or reference to the derived class reference or pointer and for that you use dynamic_cast operator. But i can hardly think of any ex...
Thirst asked 7/7, 2020 at 14:33
6
Solved
I am learning c++ and am learning about the virtual keyword. I have scoured the internet trying to understand it to no avail. I went into my editor and did the following experiment, expecting it to...
Grot asked 27/7, 2017 at 17:45
4
Solved
If a dependency container, or data access factory, can return types that may implement IDisposable, should it be the client's responsibility to check for that and handle it? In my code below, one d...
Twowheeler asked 6/1, 2014 at 15:59
1
Solved
Why do arrow functions take precedence over function declarations in JavaScript Classes?
Example :
class Parent {
work = () => {
console.log('This is work() on the Parent class');
}
}
c...
Twinscrew asked 10/6, 2020 at 10:30
2
Solved
I'm working with JacksonPolymorphicDeserialization, this is my code which deserializes into the proper class based in the 'type' property:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = J...
Soviet asked 11/4, 2013 at 9:36
3
Solved
In the code below it is not possible to obtain a reference to a trait object from a reference to a dynamically-sized type implementing the same trait. Why is this the case? What exactly is the diff...
Instead asked 7/8, 2019 at 15:47
1
Why shouldn't multimethods in Clojure simply be replaced by cond expressions?
I was inspired to ask after looking at the simple examples of multimethods in Ch. 5 of Russ Olsen's book Getting Cloj...
Schwenk asked 28/5, 2020 at 5:12
2
Solved
I have a question about this code right here
public Car {
public static void m1(){
System.out.println("a");
}
public void m2(){
System.out.println("b");
}
}
class Mini extends Car {
public...
Arjun asked 4/12, 2012 at 4:16
2
Solved
I am trying to use polymorphism in generic type parameters in C#. I have reviewed several other questions on SO (1, 2, 3, 4, 5, 6), but I'm still not clear why this doesn't work (or if it's even al...
Visigoth asked 26/7, 2017 at 9:51
3
Solved
I've recently read an article/code snippet that shows an example of replacing conditionals with polymorphism. Here is the code:
Before:
def log_msg(log_type):
msg = 'Operation successful'
if l...
Dex asked 1/7, 2014 at 18:32
9
Solved
Say we have:
class Base
{
virtual void f() {g();};
virtual void g(){//Do some Base related code;}
};
class Derived : public Base
{
virtual void f(){Base::f();} override;
virtual void g(){/*...
Nebula asked 29/12, 2008 at 9:48
1
Solved
Given the following code:
class Kitten {
private String name = "";
public Kitten(String name) {
name = name;
}
public String toString() {
return "Kitten: " + name;
}
public boolean equa...
Bangtail asked 28/4, 2020 at 6:29
© 2022 - 2024 — McMap. All rights reserved.