Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
48 views

How to inherit from a sealed class in Kotlin?

This quesiton is based off of the answer in How to extend enums in Kotlin?. I tried to implement one of the answers in this post, but it's not working as I expected it to. I want each implementation ...
TableTopRug's user avatar
0 votes
1 answer
46 views

Passing in a generic templated subtype

Let's say I have a templated, abstract Fish class with two templated children: template<typename T> class Fish { public: virtual ~Fish() = default; // Pure virtual method to make Fish ...
Moish's user avatar
  • 574
-7 votes
1 answer
97 views

Is making an enum public disrespecting encapsulation?

This is a question for an assignment for Uni. For this assignment we have to respect encapsulation and inheritance in Java. The important classes to know right now are: Cliente Class import java.util....
MiguelPereira3530's user avatar
-1 votes
0 answers
58 views

main does not compile when creating a class object [duplicate]

I recently started C++ and it has been fun, but now I'm stuck trying to test inheritance classes (and classes in general). When you create a class, the more organized way to do it (as far as I've been ...
Alex JB's user avatar
  • 17
1 vote
1 answer
80 views

Address of 'this' pointer in Inheritance hierarchy

I was debugging some legacy code and while doing that found some inconsistency in the address of this pointer in the class hierarchy like this: #include <cstdio> #include <vector> class ...
Ameya Babhulgaonkar's user avatar
2 votes
2 answers
40 views

Conditional types with an inherited class in a generic function

I'm not sure how, given the following class structure and function: class ClassA<T> {} class ClassB<T> extends ClassA<T> {} class ClassC<T> extends ClassA<T> {} ...
Big Green's user avatar
0 votes
3 answers
62 views
+50

Is there way to have polymorphic behaviour for convertors from DTO to model?

I have endpoint which accepts BaseDto: @JsonTypeInfo(...) @JsonSubTypes({ @JsonSubTypes.Type(...), ... }) @RequestMapping( method = RequestMethod.POST, value = "/path", ...
gstackoverflow's user avatar
2 votes
1 answer
79 views

how to find out the duplicate fields define in both java base class and subclass

I have a java base class defined like this: @Data public class BaseClass { private Long id; ...... } the subclass look like this: @Data public class SubClass extends BaseClass { ...
Dolphin's user avatar
  • 37.9k
0 votes
1 answer
16 views

how could I write a pytorch model in diamond inheritance way?

I need to implement a complex model, and I better to use Diamond inheritance to satisfy different requirements, here is the toy code to show what I am trying to do: import torch import torch.nn as nn ...
coin cheung's user avatar
  • 1,097
0 votes
0 answers
11 views

Modelio Class diagram doesn't propagate properties and methods;

In Modelio I've created a class 'person', with 'Name' and 'Age' as properties. Then I create a class called 'employee' that inherites from the class 'person' using a 'Generalization (inheritance link)'...
Dennis's user avatar
  • 1,548
1 vote
1 answer
47 views

PHP inheritance in constructor

I'm doing tests. Given this code snippet <?php class Point { public $x; public $y; public function __construct($x, $y) { $this->x = $x; $this->y = $y; } } ...
StarNab's user avatar
  • 43
0 votes
1 answer
36 views

Lua inheritance and instanceof

I'm trying to port some Java code to Lua, while maintaining class inheritance I want to use an instanceof Lua implementation. Here are the modules I define: -- ClientWidget class local ClientWidget = {...
Arnault Bonafos's user avatar
0 votes
2 answers
32 views

Principled Conditional Inheritance in Python

I have a class that inherits np.ndarray: class A(np.ndarray): def __new__(cls, foo: np.ndarray): # Operate on foo... x = np.array([1.]) + foo # (placeholder) return x def bar(self, x)...
Richie Bendall's user avatar
1 vote
0 answers
31 views

Spring JPA Single Table inheritance clause order in query

Spring Data Jpa allows for inheritance with multiple strategies, one of them being Single table, in which a discriminator column is used to differentiate among various child classes. Suppose we have @...
Daniel Pop's user avatar
2 votes
1 answer
61 views

Errors Implementing Simple .NET MAUI Page Inheritance in .NET MAUI

I have a .NET Maui problem. I have been struggling with all day: I am creating my first app, a simple Home Maintenance Tracking application. I have 4 very similar screens, so I decided to implement a ...
Bill Boswell's user avatar
0 votes
0 answers
14 views

How can I override child parent inheritance in react native (JSX)?

I have a ScrollView and within it Text. I'd like the ScrollView to have 0.4 opacity and for the Text inside it to have full opacity (1). My problem is that because of inheritance the child component ...
Omer Giladi's user avatar
0 votes
1 answer
59 views

Ignoring a base type in Entity Framework Core 9 code-first

I typically use the following interfaces for EF Core entities (.NET 9, EF Core 9): public interface IEntity where TEntity: class, new() { // Identity column. public long Id { get; set; } ...
Raheel Khan's user avatar
  • 14.7k
0 votes
0 answers
47 views

Entity Framework Core 8 - Mapping Two Entities to the Same Table with Different Filters (PostgreSQL)

I'm using .NET Core 8 with Entity Framework Core to connect to a PostgreSQL database. I need to create two objects, objectA and objectB, which both reference the same table, but with different ...
livisghton araujo's user avatar
0 votes
1 answer
58 views

C# default interface implementation transitivity -- why am I getting this error?

I have come across a scenario where I want to use a default interface implementation in .NET 8.0 that I am having trouble with. In the simple example shown below, my compiler is complaining that Baz ...
Sidney's user avatar
  • 698
0 votes
1 answer
67 views

Type hinting in Python 3.12 for inherited classes that use the parent class method without typing module

I have a parent class that I made along with a number of child classes that inherit from the parent class. These classes are essentially just python models to read certain documents in from a json or ...
user2731076's user avatar
0 votes
0 answers
49 views

How is it possible to access Object class methods using an interface reference variable? What is the underlying mechanism that allows this to work?

I am working on a Java project and I have defined an interface, a class that implements this interface, and a user class to test the implementation. I am confused about how I can call methods from the ...
Mohammed Raheel's user avatar
4 votes
1 answer
123 views

In which scenario are non-final non-virtual classes like std::-classes useful?

A base class in C++ should have at least a virtual destructor, if I inherit from the class. Therefore, one should e.g. better not inherit from std::optional. The answer here says If it doesn't have ...
Thomas Weller's user avatar
3 votes
1 answer
124 views

Inherit assignment operator failure c++

Snip: #include <optional> template <typename> class MyOpt; template <typename T> MyOpt(T) -> MyOpt<T>; template <typename T> class MyOpt : private std::optional<...
Juergen's user avatar
  • 3,733
0 votes
2 answers
76 views

Flutter : force createState() for inherited StatefulWidget

Edit: solved by adding a unique key to the widget constructor call: Edit 2: as Randal Schwartz mentioned -> this is not a solution. Issue NOT solved and still open. @override SearchTermInput ...
user28298940's user avatar
-1 votes
2 answers
43 views

How does React props work with es6 and object inheritance between classes

I don't even know if this is possible, something told me to do functional components but I am already too far deep into the code and I am scared to go back (this is an issue I must learn to tackle but ...
barrington hebert's user avatar
-2 votes
1 answer
78 views

c++ problems with polymorphism and inheritance

I can't get why this code prints E::n() A::m() E::j() if i run (p4->n()).m(); #include <iostream> using namespace std; class A{ public: A() {cout << "A() ";} ...
lostH's user avatar
  • 21
-1 votes
1 answer
74 views

Calling Super function from child function

I have the following structure: class grandparent(ABC): @abstractmethod def get_obj(self): pass class ParentBase(grandparent): def __init__(self, obj1): self.obj1 = obj1 ...
Rezzy138's user avatar
0 votes
1 answer
51 views

What is the name of the XML file that generates the PDF invoice report and how can I know it?

I am trying to add a new column (Number of Members) to the PDF invoice and hide the tax column. When I generate the PDF file, no change happens. I want to know which XML file generates the invoice. ...
Aws Dayoub's user avatar
0 votes
1 answer
61 views

Is it possible to truly "seal" a class function so it cannot be overridden in subclasses in any way?

Core question explained via code: Say I have an interface public interface IWorker { void DoWork(); } Now, setup an abstract class implementing this interface. I want this abstract class's DoWork() ...
Avery Ferrante's user avatar
-3 votes
2 answers
51 views

Inherit from the generic class CompletableFuture

I wish to write async/await code which is JS-friendly, however, my class inheritance doesn't seem to work: import java.util.concurrent.CompletableFuture; class Main { public static class Promise&...
Dan D.'s user avatar
  • 8,487
0 votes
1 answer
57 views

How to fix order of inherited subclasses in Python Dataclass

I am trying to create a Dataclass for a Latitude&Longitude using inherited subclasses of Latitude and Longitude. But the order of the inherited subclasses is incorrect. from dataclasses import ...
akarich73's user avatar
-1 votes
1 answer
52 views

How to assign MemoryStream to a custom class that inherits from MemoryStream

I have class MemoryStream2 that inherits from MemoryStream, the only difference is that it introduces a new variable - reference id. Now I have a situation where a certain function returns ...
George's user avatar
  • 2,215
-2 votes
3 answers
125 views

Can a std::vector of std::shared_ptr hold pointers to different subclasses of the same base class? [closed]

I have been attempting to create a dynamic data structure to hold a number of objects of different classes, all of which derive from the same base class. I have found advice in may places that this ...
Smoggie Tom's user avatar
0 votes
1 answer
37 views

Creating Independent Parent Attributes in Pydantic

I have an activity class like this: from datetime import datetime from typing import Optional from pydantic import BaseModel, Extra, Field class Activity(BaseModel, extra=Extra.ignore, frozen=True): ...
teajay's user avatar
  • 13
1 vote
1 answer
113 views

How to specialize on parameters other than `this` in Java

Consider the following example: abstract class Numeric { abstract public Numeric add(Numeric other); } class Real extends Numeric { private double inner; public Real add(Real other) { ...
William Ryman's user avatar
1 vote
1 answer
24 views

Roxygen with a function made just to hold parameter definitions

I have a package with many functions that use the same parameters and should have the same documentation for those parameters. I can certainly use @inheritParams, but there is no single function that ...
zackelaz's user avatar
0 votes
1 answer
21 views

Does it matter where I put "extends" in GDScript?

Reading tutorials for Godot I've seen both e.g. extends StaticBody2D class_name Foo and class_name Foo extends StaticBody2D Are these equivalent? Is one preferred over the other? (And if so, why?)
user1445709's user avatar
0 votes
0 answers
27 views

Why is this JavaScript prototype inheritance returning undefined? [duplicate]

I've been racking my brain over this and can't figure out why the first console.log is returning undefined but the second one works fine. Any help would be much appreciated it's driving me crazy. ...
cobbdb's user avatar
  • 629
0 votes
0 answers
37 views

Base class properties and methods from a library class are not being inherited into my subclass

I can't seem to properly inherit a base class into my custom class, in this case, the ServiceInfo class from the zeroconf library into my custom MdnsServiceInfo class. While testing out workarounds I ...
Raul Marquez's user avatar
  • 1,116
1 vote
0 answers
62 views

Priority Queue inherited struct not in scope C++ [duplicate]

i am implementing a custom priority queue witch inherits from a custom queue class. when i try to compile, i get an error saying the node struct is not in scope. The error: make g++ -O2 src/test.cpp -...
user28128572's user avatar
0 votes
1 answer
59 views

C++ Base Class taking Type Parameter from Child Class

I would like to have a base class Collection that defines the following interfaces. The base class itself should implement none of this data but instead all of them should be provided by the child ...
Smiley1000's user avatar
1 vote
1 answer
88 views

When an aggregate inherits from an aggregate, is there risk of object slicing or memory leaks?

I am reading some material about C++17, I have a question about inheritance between aggregates. If an aggregate inherits from an other aggregate, isn't it a problem ? Is there not any risk of slicing ...
Oodini's user avatar
  • 1,189
0 votes
1 answer
30 views

Is it safe to use dataclasses with hidden/non-field inherited properties?

I have a dataclass use strategy that is quite flexible, but I am unsure if it is relying on features that aren't part of the type contract. I am often telling people to not rely on the insertion order ...
probinso's user avatar
  • 307
2 votes
0 answers
73 views

Is moving a public property to base class a breaking change in a public API [closed]

I ran into a problem I have not seen before. I'm using a 3rd party assembly that comes in two different versions. I compile against one of them and load the correct version at runtime. The version I ...
adrianm's user avatar
  • 14.7k
1 vote
1 answer
28 views

Can view in psql inherit comment from table on simple columns?

Suppose I have dummy table like this: CREATE TABLE test_table (value INT); And a comment on that column: COMMENT ON COLUMN test_table.value IS 'Test comment'; Then, I create a view on my table: ...
grga-gc's user avatar
  • 13
-1 votes
1 answer
37 views

Shared class inheritance

While I am aware this is weird, I still want to know if it can work mainly for improving understanding. Basically, it is inheriting a class, but also from the parent class being able to call methods ...
user3456886's user avatar
1 vote
2 answers
52 views

Best pratice to construct a CustomException with a custom message

I have a CustomException class that inherits from Exception, so I'm trying to understand the best practices to construct such an object. This exception would need to construct its own exception ...
Luis Angel Urena Lopez's user avatar
1 vote
1 answer
140 views

What's the best way to get the derived class from a base type pointer?

I tried two different ways to get a pointer to the derived class from a base pointer. One is: struct BaseClass { protected: int offset_of_derived; public: template <typename T> T* ...
Zebrafish's user avatar
  • 13.8k
0 votes
0 answers
114 views

NotSupportedException: Serialization and deserialization of 'System.Reflection.MethodBase' instances is not supported

So I tried to refactor code to return responses in a cleaner. But I can't seem to wrap my head around why when I try to put the errorResponse in the ResponseBody it returns not supported exception. ...
zhrgci's user avatar
  • 654
0 votes
0 answers
26 views

ASCX inheritence

I have a User Control in CheckBoxList.ascx: <%@ Control Language="c#" AutoEventWireup="true" Inherits="CheckBoxList" Codebehind="CheckBoxList.ascx.cs" %> &...
Damien R's user avatar

1
2 3 4 5
857