inheritance Questions

2

Solved

In this example code, why isn't using IParameterBase<TYPE>::operator=; working, and the base class assignment operator working? I recently changed to this templated version, previously I had ...
Lucifer asked 3/10 at 11:39

2

Solved

from pydantic import BaseModel class A(BaseModel): date = '' class B(A): person: float def __init__(self): self.person = 0 B() tried to initiate class B but raised error AttributeError: '...
Parcenary asked 25/11, 2022 at 12:39

5

Solved

I'm reading J. Bloch's Effective Java and now I'm at inheritance vs composition section. As far as I understood he said that inheritance is not always good. A related cause of fragility in subcl...
Sidon asked 26/6, 2015 at 14:40

2

Solved

I'm wondering if there is any good reason why this behaviour is possible in the current PHP 5.4 implementation: trait T { public function test(PDO $pdo) {} } class C { use T; public function t...
Satanism asked 17/7, 2012 at 11:21

6

Solved

I am basically trying to implement a Strategy pattern, but I want to pass different parameters to the "interfaces" implementation (that inherit from the same object) and don't know if this is possi...

6

Solved

I have a base class Character which has several classes deriving from it. The base class has various fields and methods. All of my derived classes use the same base class constructor, but if I don...
Basidiomycete asked 28/11, 2010 at 13:9

3

For torch.nn.Module() According to the official documentation: Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allo...
Referent asked 18/4, 2020 at 11:19

5

Solved

Now, if the title sounds weird to you, consider this code, I was reviewing today (simplified): public class MyService( IHttpClientFactory httpClientFactory) : BaseService(), // WTF? a Method? I...
Neutron asked 20/8 at 7:27

5

I'm just getting started with Node.js, so I'm building very simple applications in order to practice the basics. I was trying to get some Django-like template inheritance working, but I'm at a bit ...
Centistere asked 4/3, 2015 at 19:25

6

Solved

I'm trying to answer the following question: A child class would not inherit certain members of the parent class. Name three such members. I know private members are not inherited to child c...
Aguilera asked 16/4, 2014 at 8:5

5

Solved

Basicly I have the following structure in my app: It would be straightforward to implement such a structure without the abstract class ProjectItem, but in this case I don't know how to implement...
Cleres asked 22/3, 2014 at 11:0

2

Solved

I've search all over this site and google and I ended up creating this account... I need some help with php, traits and classes. I have this 2 different traits, that have some methods with the same...
Heddie asked 11/5, 2014 at 17:23

8

Solved

suppose a class has private data members but the setters and getters are in public scope. If you inherit from this class, you can still call those setters and getters -- enabling access to the priv...
Shuler asked 20/4, 2010 at 15:34

3

Solved

I have this example: #include <iostream> #define print(X) std::cout << X << std::endl struct B1 { B1(int _i = 5): i(_i) { print("B1 constructor"); }; int i; }; struc...

4

I try to figure out what is the best practice in Python inheritance principles, when there is a 'bad idea' to change method signature in a child. Let's suppose we have some base class BaseClient ...
Handfasting asked 5/8, 2017 at 14:44

6

Solved

I have following: Assembly asm = Assembly.GetAssembly(this.GetType()); foreach (Type type in asm.GetTypes()) { MyAttribute attr = Attribute.GetCustomAttribute(type, typeof(MyAttribute)) as MyAtt...
Kramatorsk asked 2/12, 2010 at 11:57

3

Solved

I would like to know regarding following behavior of instanceof operator in Java. interface C {} class B {} public class A { public static void main(String args[]) { B obj = new B(); System.o...
Skepful asked 14/7, 2015 at 5:39

4

Solved

I want to exclude all inherited methods from trait(s) from the list that are not overriden in a class So how to know if a class member is inherited from trait? Yes, I can check it like this: if ...
Dustpan asked 5/6, 2015 at 8:38

5

Solved

Exists in the Perl world any template system with template inheritance? Just checked in the wikipedia Comparison_of_web_template_engines (really incomplete list) - and here isn't listed any. In...
Avril asked 9/1, 2014 at 10:58

4

Solved

EDIT: I changed a bit the example for getting the idea: Like <Integer or Float> ...without having to create a common interface and make a subclass for Integer and Float to implement it ...
Rhymester asked 24/7, 2012 at 14:42

4

Solved

Why does Spring automatically choose the superclass types during autowiring? For instance, if I have @Component public class Foo {} @Component public class Bar extends Foo {} and someone autow...
Witch asked 22/5, 2013 at 4:20

2

Solved

If the base class and derived class both have their constructors with parameters then where we pass the parameters to the base class constructors?
Proudfoot asked 5/5, 2014 at 20:40

5

Solved

I have this scenario: class A<T> I want a constrain of type Person like class A<T> where T: Person and I want A to inherit from B too. example: class A<T> : B : where T:...
Yearning asked 8/4, 2014 at 14:33

4

Solved

Say I have a super class "Animal" and subclasses "Cat", Dog, Bird". Is there a way to have an array of subclass type rather than class instances with which I'll be able to instantiate instances of ...
Knighterrant asked 19/7, 2013 at 3:0

6

First question: I am working with pandas' DataFrames and I am frequently running the same routines as part of data pre-processing and other things. I'd like to write some of these routines as meth...
Glyco asked 21/12, 2017 at 4:19

© 2022 - 2024 — McMap. All rights reserved.