Questions tagged [overriding]

Method overriding, in object oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes.

Filter by
Sorted by
Tagged with
0 votes
0 answers
11 views

How to mark a Scala var as partially overriding a parent

Consider the following simple trait trait Parent { def x: Int = 0 } Now consider an implementing class that wishes to define x to be mutable. class Child extends Parent { var x: Int = 1 } This ...
Silvio Mayolo's user avatar
-2 votes
0 answers
28 views

Override var body: some View in custom swiftui class [closed]

Is there any way in swift to override a computed property/ method that returns an opaque type. In the context of Swift programming, I am currently exploring methodologies to override a computed ...
Trevor Clute's user avatar
1 vote
2 answers
102 views

Why can variables in Kotlin be overridden, while in Java, they cannot?

In java, variables cannot be overridden but can only be hidden. Whereas in kotlin, we can override the variables. Though they both run on JVM, why is this difference? Is it because the variables in ...
MoeJoe's user avatar
  • 21
1 vote
2 answers
89 views

Is it possible to overload the implementation of a pure virtual function in the child class?

I am working on a project in which I have a base class called MSTAlgorithm (Minimum Spanning Tree Algorithm). Two classes called PrimsAlgorithm and KruskalsAlgorithm publically derive from this base ...
Blargian's user avatar
  • 316
0 votes
0 answers
33 views

passing a variable and its value from one class to another through inheritance c#

I want to use inheritance when calculating the area and volume of a cone. I have a circle class whose variables I want to use. I don’t understand why the area value is not transferred and calculated ...
Nenavizhu_Sumerki's user avatar
0 votes
1 answer
30 views

Set Button.type to "button" by default

I'd like it that when I create a new button, it's type is set to "button" by default. Here's what I've tried: var createE = document.createElement; document.createElement = (str) => { ...
ControlAltDel's user avatar
-1 votes
2 answers
86 views

c++ how can i access virtual method in a template class which will be overriden in derived class

I have a templated Base class with 2 virtual methods begin() and end(). I also have Derived1 class derived from Base class, and Derived2 class derived from Derived1 class. I am overriding method begin(...
Miroslav Krajcir's user avatar
1 vote
2 answers
66 views

Trying to create a C# program that uses auto-implemented properties, overrides ToString(), and uses a child class

I'm going to try to be as clear as possible, but bear with me. I need to make a program that: Create a class named LetterDemo that instantiates objects of two classes (named Letter and Certified ...
gabbi368's user avatar
0 votes
1 answer
71 views

WPF Extended Textbox Override not working correctly

I have created a CustomTextBox which extends TextBox. I have overridden the Metadata for TextProperty because I want to trigger a method when the text changes, but when I run my code and edit the ...
Richard Gale's user avatar
  • 1,856
0 votes
0 answers
40 views

Why is the paintComponent() method executed without being called?

i am just learning Java , today i ran into a problem while practicing. first, I inherited from JPanel and drew a diagonal line using the paintComponent method. but in the main class of the program, I ...
amir's user avatar
  • 11
0 votes
3 answers
47 views

'No suitable method found to override' in Unity 2022.3.14F1

I was watching the Steam online tutorial for Unity on YouTube and I came across this error in Unity: 'CustomNetworkManager.OnServerConnect(NetworkConnection)': no suitable method found to override ...
shad0ww's user avatar
-2 votes
0 answers
30 views

How to overload(override) cin operator >>? [duplicate]

I want to design that something particular character entered, console output "good" string x int y cin>>x cin>>y in this program, if (x and y are all) == "0", i want to ...
이웅기's user avatar
0 votes
0 answers
65 views

How to prevent JFrame from being decorated

I was working on JRootPaneUI (I am trying to develop a look and feel), and I was making a window with rounded corners. The issue is if I do not use setShape, it would leave some artifacts on the ...
Also Grinding For Reputation's user avatar
0 votes
1 answer
38 views

Overrides usage in package.json

I've got a packages dependency that I need to update, so I've been trying to use overrides in my package.json, however this doesn't seem to work In my package-lock.json file I can see the following; &...
Neil Kelsey's user avatar
0 votes
1 answer
26 views

How to write equals method using Apache commons-lang3?

package org.sudoku; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.*; public class SudokuBoard { private final ...
jano's user avatar
  • 23
1 vote
0 answers
30 views

Minecraft Fabric: Overriding vanilla registries

I'm developing a mod for Minecraft 1.18.2 using Fabric. I'd like my mod to replace all the vanilla birch trees (or whatever) in the game with my custom ones (or whatever). To do this, I'm trying to ...
LanGvest's user avatar
0 votes
0 answers
47 views

odoo 16 override js calendar function

I want to override the function useFullCalendar in /web/static/src/views/calendar/hooks.js. if I import: with import {useFullCalendar} from "@web/static/src/views/calendar/hooks"; I always ...
klausjulius's user avatar
1 vote
0 answers
50 views

get hidden derived property from base class [duplicate]

The classA has property pA which has type of baseType. I have created classB derived from classA and it is hiding pA property with "new" modifier: newType pA; newType derived from baseType......
Zsolt v's user avatar
  • 21
0 votes
1 answer
40 views

Unable to archive mutiple files in a single tar using ansible

I wish to compress the comma separated files in variable {{ sourcefiles }} into HELLO.tar on the target source_host and bring it to Ansible controller using fetch module and unarchive (while retaining ...
Ashar's user avatar
  • 3,033
0 votes
1 answer
89 views

C++ Create a Function that acts like a listener

I don't know what to properly name this but is there a way to create a function on a separate thread that acts as a listener so that other functions can sort of attach to it in a way? Allowing that ...
drilager60's user avatar
1 vote
2 answers
58 views

How do the overrides happen when attributes are added in an interface?

interface I{ String s="I"; } class A implements I{ String s="A"; } class B extends A{ String s="B"; } class Demo extends B{ String s="C"; ...
Chinthaka Prasad Wijerathna's user avatar
0 votes
1 answer
45 views

How can I override built in Flutter Widget's functions?

I want to change just a few lines of code in tabs.dart file: void _handleTap(int index) { assert(index >= 0 && index < widget.tabs.length); _controller!.animateTo(index); widget....
Gamer Yigit's user avatar
-2 votes
1 answer
46 views

Java polymorphism top level method is called

I have an inherited object in a java project and I am trying to call the overriden method in the child object. For some reason the parent version of the method is being called. It was my understanding ...
Austin's user avatar
  • 336
0 votes
0 answers
51 views

Can't figure out how to override variables in dataform

I'm encountering difficulties figuring out how to overwrite execution variables in releases using Google Dataform. I have a repository set up with three main components contributing to this issue: a ...
Facundo Bugarin's user avatar
0 votes
0 answers
24 views

Remove the number fields from product URLs in Prestashop 1.7

The URLs of the product pages which have combination items contain a number next to it, such as this example below https://example.com/nut-butters/4-103-natural-peanut-butter.html I would like to know ...
Yoosuf's user avatar
  • 892
-2 votes
1 answer
64 views

How to reuse code in GoLang in the absence of interfaces or function overriding?

I would like to know how GoLang handles code reuse without inheritances and function overrides. Below is an example of what I am facing now. I have a code base that handles POSTing an array of an ...
Yalda's user avatar
  • 684
0 votes
0 answers
17 views

How to check if a method has been overridden in a data class object in Kotlin?

My problem is differentiating the methods created by the data class with the methods created manually by the person. I'm trying to find a way to differentiate the methods created by the data class ...
Lotexiu's user avatar
1 vote
0 answers
124 views

Difference between `public` and `private` inheritance when inheriting from abstract classes

I have a class Placeable: struct Placeable { virtual void place_at(int x, int y) const {} virtual ~Placeable() = default; }; I also have several other types, such as Box, that inherit from ...
Christopher Miller's user avatar
0 votes
0 answers
7 views

how do i make the square go up in :hover after the animation ends?

i use separate tags for transition and animation, but still they dont work together i need the red square to lift up after being hovered over with a cursor after the animation ends i wanted to make ...
Danko Grgić's user avatar
0 votes
2 answers
109 views

Overriding a method with a sealed class/interface parameter in java

Given this java code: public class Main { public static void main(String[] args) { // These are objects of the only 2 classes that implement Parent // `sealed` defines that there ...
Rik Schaaf's user avatar
  • 1,113
0 votes
0 answers
7 views

I use joomla 4.2.6 and pagebuilder .The addon form builder dont work properly

I am using joomla 4.2.6 and i am trying to change my contact form . I cant change the style .The addon has options for changing colour,border etc but it doesnt work . The code from inspector(this code ...
Ellie's user avatar
  • 1
0 votes
2 answers
42 views

Wordpress php function wp_upload_dir() derived path I apply in functions.php is being overridden

Putting a basic js arcade game in a single post on WP website with Newspaper theme - hosted locally by WAAMP on my laptop. In functions.php the javascript files links are added to the footer. The ...
kiwiLifter's user avatar
1 vote
1 answer
37 views

AttributeError trying to define a setter for an inherit attribute in a subclass

I have defined a base class using dataclass annotation and I want to override the setter for one of the attributes in a derived class. from dataclasses import dataclass, field @dataclass(repr=False, ...
Manu's user avatar
  • 35
0 votes
1 answer
75 views

Runtime Polymorphism and Virtual function

Can we achieve runtime polymorphism(method overriding) without virtual function in C++ I think that since it is runtime it should only be possible through pointers using virtual functions but we can ...
Abhishek's user avatar
0 votes
1 answer
21 views

Kotlin: how to have abstract values as default arguments for abstract functions?

I have a sealed class that represents my screen states, and the different screen states are data classes, since I want to be able to copy them while changing just one value. Unfortunately Kotlin doesn'...
Felipe Ribeiro R. Magalhaes's user avatar
3 votes
1 answer
104 views

Why Java compiler creates bridge methods for methods without parameters (getter methods)

I do understand the need to create bridge methods for example a setter method that expects an argument to be passed, but what about a getter method? Why does Java produce a bridge method as well? Here ...
stathis94's user avatar
0 votes
1 answer
93 views

Check @Override annotation presence on method

I have a java.lang.reflect.Method method and I want to check if it is marked with @Override annotation. Was trying to do that with method.isAnnotationPresent(Override.class) but this approach doesn't ...
Ксения Лабутина's user avatar
0 votes
2 answers
169 views

How to implement such kind of class hierarchy in go?

package main type barer interface { bar() } // Actucally base is a complex type and it has dozens of // membets and methods to make itself as a base. type base struct { barer } func (b *...
api's user avatar
  • 321
0 votes
0 answers
48 views

How to override max-width value in media screen query using PrimeNg menubar?

In my Angular project, I'm using PrimeNG components. In my angular.json file I have the following lines "styles": [ "node_modules/primeng/resources/themes/saga-blue/theme.css&...
fcjunic's user avatar
-1 votes
1 answer
60 views

How to use object from class A in class B?

i have [Class Basic] and [Class squash]. then i wanna use 'LWheel01Con'controller created in [Class Basic]. i really dont know how to do it!! please help me ;( im very beginner of python, so plz ...
lusina Mendel's user avatar
0 votes
0 answers
32 views

flutter invalid override, scroll indicator isnt valid override

I'm new to flutter and dart, and having a problem with override my custom widget. here is my code, class SBehavior extends ScrollBehavior { @override Widget buildOverscrollIndicator( ...
chanwoo Hwang's user avatar
0 votes
1 answer
99 views

How to override anonymous function in JavaScript with Tampermonkey?

I have a function I want to override in an anonymous function with Tampermonkey. (()=>{ /* other stuff */ function Zm(e) { let {visible: t, onCancel: n} = e; const ...
ZeroPhase's user avatar
  • 649
-1 votes
2 answers
83 views

Out of bounds address when overriding virtual class method in cuda kernel

For the project I'm working on, I have defined a certain base class and several derived classes that inherit it. The base class has several virtual methods that are overriden by methods in the derived ...
cyanmess's user avatar
0 votes
1 answer
36 views

Python expressions in f-strings do not return same result as str() conversion for subclasses? [duplicate]

For example, we override the __str__ method in Decimal then call it two different ways from decimal import Decimal class D(Decimal): def __str__(self): return super().normalize().__str__() ...
goweon's user avatar
  • 1,151
4 votes
1 answer
148 views

Can I @override the following @overloaded Python function?

The PySide6 function QComboBox.addItem is type-hinted, in QtWidgets.pyi, like this: @overload def addItem(self, icon: Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap], text: str, userData: Any = ...) ...
bers's user avatar
  • 4,944
0 votes
0 answers
101 views

Chrome DevTools Local Overrides Not Reflecting Changes in Webpack Source Maps

I've been experimenting with the Chrome DevTools' local overrides feature to modify a specific JavaScript file on a website. However, I've run into an interesting situation that I need some guidance ...
Mithun's user avatar
  • 1
0 votes
2 answers
48 views

Access Virtual Function In Interface Directly From Implemented Class

Say I have the following function: public interface MyInterface { int GetNumber(); virtual int GetTwiceNumber() => 2 * GetNumber(); } I can implement the interface in a class as ...
Brendan Lynn's user avatar
0 votes
0 answers
33 views

What is the proper way to override a method's return type in TypeScript?

In the Point2D class below, I got the compiler to stop complaining about the following error: Property 'clone' in type 'Vector2D' is not assignable to the same property in base type 'Point2D'. By ...
Mr. Polywhirl's user avatar
0 votes
1 answer
49 views

override sync function which is in BelongsToMany || laravel 9

I need to override the sync function which is in BelongsToMany inside the InteractsWithPivotTable Trait becuse I want to add scope when detaching <?php use Illuminate\Database\Eloquent\Model; ...
abdul rahman souda's user avatar
0 votes
1 answer
68 views

Encountered a strange inheritance problem in unity3d

There are three classes: the parent class, the subclass, and the Main class Parent Class using UnityEngine; public class Parent : MonoBehaviour { protected float m_hp = 2000; public virtual ...
josep16388's user avatar

1
2 3 4 5
163