polymorphism Questions
0
I have a hierarchy of polymorphic classes. At some level in the hierarchy, I want to make the implementation of a virtual method final.
Additionally, I just want to use the base class implementatio...
Buckra asked 30/9 at 8:17
5
Solved
I know the behavior, but I am not 100% sure on why this occurs.
I understand that there is no polymorphism for instance variables in java. The variables are resolved statically by the compiler.
But...
Blastoderm asked 20/8, 2012 at 21:52
7
Solved
I have base class as Animal and child class as Dog
Here is the code:
class Animal
{
public int Legs { get; set; }
public string Name { get; set; }
}
class Dog : Animal
{
public int noOfTail ...
Airtight asked 3/2, 2018 at 10:40
1
I've seen both used interchangebly but do they really mean the same? From my understanding, Polymorphism stretches the fact that you could exchange an instance of a class by an instance of a subcla...
Camfort asked 8/9, 2010 at 18:18
1
Solved
Let's assume I have the following code (https://godbolt.org/z/MW4ETf7a8):
X.h
#include <iostream>
struct X{
void* operator new(std::size_t size)
{
std::cout << "new X\n";
...
Alcaic asked 24/6 at 21:25
4
Solved
I'm covering polymorphism and I'm trying to see the practical uses of such a feature.
My basic understanding of Rank 2 is:
type MyType = ∀ a. a -> a
subFunction :: a -> a
subFunction el ...
Troytroyer asked 9/1, 2017 at 22:21
4
Solved
The below code shows my problem. Effectively, I am trying to use Mockito's ArgumentCaptor to verify that a method was called once with a certain concrete class. I would like to use ArgumentCaptor h...
Tholos asked 23/3, 2011 at 10:19
21
Solved
I have a solid understanding of most OOP theory but the one thing that confuses me a lot is virtual destructors.
I thought that the destructor always gets called no matter what and for every object...
Oldfangled asked 20/1, 2009 at 12:58
2
I have a polymorphic model:
public class CreateOrderRequest
{
public List<CreateOrderItem> OrderItems { get; set; }
}
/// <summary>
/// Identifies a new item within an order
/// <...
Rapt asked 4/9, 2017 at 22:42
4
Solved
Do polymorphism and operator overloading mix together?
You can't do polymorphism without pointers, as it is explained in this answer and also you can't do operator overloading with pointers as expl...
Gothicize asked 29/6, 2012 at 8:43
4
Is there a way to create a polymorphic add function in OCaml that works equally well for ints and floats? So for example if I have a function like:
partialsums [1; 2; 3; 4; 5] I should get [1; 3; ...
Freeholder asked 8/6, 2016 at 5:57
5
Solved
I am learning go lang and i was wondering if there is a way to do something like this:
type Foo struct {
...
}
type Bar struct {
Foo
...
}
func getFoo() Foo {
return Bar{...}
}
In an objec...
Fisken asked 31/1, 2016 at 15:11
4
I would like to define a polymorphic table. My problem being that one table's primary_key is of type uuid(string) and the other id(integer).
I thought maybe having a model_able_id and a model_able_...
Kilo asked 23/1, 2018 at 17:27
2
Solved
I would like to model a database entity for a set of players.
Each player should have :
a number of fixed fields (name, role, ...)
a number of variable fields for skill levels (if role is ATK, ...
Uriia asked 15/11, 2016 at 10:41
0
I just got a juicy race condition. Consider the following classes:
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
class A
{
std::thread th;
std...
Bomar asked 22/9, 2023 at 14:7
10
Solved
I am writing a method that should accept as its parameter an object of one of two types which do not share a parent type other than Object. For example, the types are Dreams and Garlic. You can do ...
Digital asked 27/5, 2012 at 21:22
5
Solved
I'm currently enjoying the transition from an object oriented language to a functional language. It's a breath of fresh air, and I'm finding myself much more productive than before.
However - ther...
Oaten asked 11/2, 2011 at 13:34
3
Solved
I ran into a problem trying to create a generic vector for a struct.
This was my first attempt:
#[derive(Serialize)]
struct Card {
sections: Vec<Section<dyn WidgetTrait>>
}
#[derive(S...
Evvy asked 25/4, 2018 at 12:5
4
Solved
#include <iostream>
using namespace std;
class base
{
int a;
public:
base() {a =0;}
};
class derv :public base
{
int b;
public:
derv() {b =1;}
};
int main()
{
base *pb = new der...
Extraterritorial asked 6/1, 2012 at 0:58
1
Is placement new of derived object within a vector / array defined to be base object legal
#include <iostream>
#include <memory>
#include <vector>
struct A
{
virtual ~A()
{
s...
Ribwort asked 1/6, 2023 at 9:24
8
Almost every C++ resource I've seen that discusses this kind of thing tells me that I should prefer polymorphic approaches to using RTTI (run-time type identification). In general, I take this kind...
Vide asked 3/3, 2016 at 6:40
28
Solved
From what I've read, virtual functions are functions in the base class that you can override in its derived classes.
But earlier, when learning about basic inheritance, I was able to override base ...
Insoluble asked 6/3, 2010 at 7:10
7
I have an Animal class with a virtual destructor, and a derived class Cat.
#include <iostream>
struct Animal
{
Animal() { std::cout << "Animal constructor" << std::end...
Anthropomorphize asked 15/5, 2023 at 11:18
2
Solved
I am trying to serialize a json, but its throwing JsonDecodingException. Check the code:
SerializationTestCase.kt:
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
...
Efficiency asked 18/3, 2021 at 12:1
9
Solved
Is there a C++ container that I could use or build that can contain, say, int and string and double types? The problem I'm facing is that whenever I try to populate, say, a map, vector or list with...
Shebat asked 19/1, 2011 at 17:14
1 Next >
© 2022 - 2024 — McMap. All rights reserved.