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.
7,849
questions
0
votes
0
answers
18
views
Is there a way to avoid code duplication in subclass?
I don't know if this kind of question has already been asked, but here is my issue. I have a basic Job -> Task service that takes the job JSON from API and converts it to a task.
A superclass that ...
0
votes
0
answers
16
views
method="post" in form tag of html does not work in servlet in java
method="post" does not work in servlet
any help would be appreciated. Thanks in advance.
I get error of -- HTTP method GET is not supported by this URL-- eventhough i use dopost method in ...
0
votes
1
answer
22
views
How to modify a Django Model field on `.save()` whose value depends on the incoming changes?
I have fields in multiple related models whose values are fully derived from other fields both in the model being saved and from fields in related models. I wanted to automate their value maintenance ...
-2
votes
3
answers
75
views
how does the 'this' pointer work in inheritance in c++?
questions:
in the code below, the 'this' pointer points to different things in base and derived classes, even though it technically contains the same address. why is that.
what is happening when the '...
0
votes
0
answers
13
views
How to override mui nested component styles in a theme?
I created a mui DataGrid with editable cells. When in edit mode, the input's padding is 0 16px by default as seen by this style that mui generated:
.css-jqsvr8-MuiInputBase-root-MuiDataGrid-...
6
votes
2
answers
76
views
How can I override a special method defined in a metaclass with a custom classmethod?
As an example, consider the following:
class FooMeta(type):
def __len__(cls):
return 9000
class GoodBar(metaclass=FooMeta):
def __len__(self):
return 9001
class BadBar(...
2
votes
2
answers
18
views
How to modify a fixture and intercept a response with the modified fixture
I am trying to modify an existing fixture and then override a response with the modified fixture.
I'm able to override the response with predefined fixture or modify the actual response, but I cant do ...
0
votes
0
answers
30
views
calling child method in parent class [duplicate]
I'm working through "Python Crash Course" from Eric Matthews and saw a line I don't understand.
I am using pygame to create a space ship-game where I want to fire some bullets from my ship.
...
0
votes
0
answers
24
views
What's the purpose of an override decorator?
My understanding to the use of a decorator is to add a constraint or extend a function.
A @override notation seems to be weird, since it doesn't(and shouldn't) to modify the function.
Then what did ...
0
votes
0
answers
27
views
hard time understanding overriding virtual private methods [duplicate]
I have this code snippet. I come from a Java background. I don't understand why the BubbleSort class sort method can access a private method in its base class and override it? This code snippet ...
2
votes
2
answers
71
views
C# properties and "tostring" method
I was trying to understand properties better and I came across this page with this example:
https://www.tutorialspoint.com/csharp/csharp_properties.htm
using System;
namespace tutorialspoint {
class ...
0
votes
0
answers
10
views
Load template inside post content
I am using load_template function , but the problem that the content is still appearing, I want to load template inside the content of the post so it will override it totally.
function load_template.
...
0
votes
1
answer
14
views
How can I overwrite a DialogService in angular kendo for the Open and Close methods?
I want to intercept the open and close events to put validation logics but that at the level of all dialogs, so the most ideal solution is to overwrite the DialogService
0
votes
1
answer
35
views
Is it possible to override the return of a controller method using a NestJS decorator?
I'd like to create an @IgnoreDev decorator that overrides a method return on a NestJS controller when it detects that we're running code in a dev environment.
For example:
@Controller()
class ...
0
votes
2
answers
31
views
Error on trying to override POST method with PUT (Method Not Allowed)
I am experiencing a "Method Not Allowed" issue when trying to override my POST request with PUT (for updating information in my blog). I already installed method override for koa.
HTML:
&...
0
votes
0
answers
21
views
Laravel overide PutenvAdapter vendor class
I want to override get, set and clear function of \Dotenv\Environment\Adapter\PutenvAdapter.
I've tried to copy and edit this file to \App\PutenvAdapterCustom.php and use ServiceProvider but it does ...
0
votes
2
answers
40
views
Scala argument upper type bounds and overriding
I am trying to understand and incorporate upper bound types with overriding in my system, but have not been able to achieve it without some ugly code. I have the following 2 traits:
trait MyId {
def ...
3
votes
1
answer
67
views
Accessing a hidden field in a subclass
According to the following quote, I expect to see overriden nullstackoverflow instead of overriden nullnull. What point did I miss?
Hiding Fields
Within a class, a field that has the same name as a ...
0
votes
1
answer
25
views
Decorate an imported class in Python
This is what I'm trying to do:
import a class.
override/decorate the implementation of one of its methods.
pass this class name to a function and that function will do something.
Typically, if I pass ...
0
votes
0
answers
25
views
override export function from node module (js)
I'm trying to override function from node module package that i use in my project
but give me error of
TypeError: Cannot set property myFunc of #<Object> which has only a getter
the strange ...
0
votes
1
answer
33
views
Using different PrincipalPermissions in an overridden method
I have a DeleteAll method in my base class that requires a specific role ("Remover") to be called. I have a second class that derives from the base class. In the derived class, I want to ...
0
votes
0
answers
12
views
Java. In arrayList of type super: add subs, why super method not overridden? [duplicate]
Java:
Classes Folk and Jazz inherit from Song. All three have method printText()
Make ArrayList "songs" of type Song
Instantiate objects from Folk and Jazz and add to arraylist "songs&...
1
vote
2
answers
90
views
C++ Function overload in the child
I have a parent DataType class from which I inherit Data Type Int, DataType Double, DataTypeEnum
and CDataTypeStruct. Somewhere I use the print () method defined by the parent and somewhere I rewrite ...
0
votes
1
answer
35
views
Overide method in gem
I am using AwesomeNestedSet and have a place in my app that calls the parent method on a model instance. In some cases, parent returns nil. That's fine but in the cases where it does I need it to ...
0
votes
0
answers
20
views
How to overide the dropEvent of QstandardItem of a QListView to get position of the dragged object and position of the place where droped
Here is my problem, I want to get the name, absolute position, and parent widget of an item from a QListView when drag and the QlistView widget where is been droped (and idealy the name or object of ...
1
vote
2
answers
79
views
How to override a method of a base class which is an input of a function?
I am trying to override a method in a code I am using to learn about this but I didn't succeed, what am I missing?
Here some code to reproduce my issue:
my_class.h
#ifndef MY_CLASS_H
#define ...
1
vote
1
answer
29
views
How to declare two types of layout access one method first one (Post) next( Ads) using one method in adapter class
Is there possibility to have post and ads methods in two class based view?
I tried to do something like this but of course it doesn't work and error it not working (layout ads) Id
enter image ...
0
votes
0
answers
13
views
Unable to override Greenlet.__init__function when gevent APIs are invoked
I am trying to override the Greenlet.init function inside the gevent package. The purpose is to maintain a list of all greenlets that are running and whose current backtrace can be dumped.
I can do ...
0
votes
1
answer
22
views
Jlabels flickering or randomly not showing
I have a problem with a Java 2d game I'm developing.
Some of the game screen elements are drawn in a Jpanel overriding the paint() method and some other elements are Jlabels added to that panel.
The ...
1
vote
1
answer
63
views
Override Lua instance function
I'm trying to change the behavior of a Lua function, by adding code to the start or end of it. Because this is a mod for a game, I can't edit the function directly, so I have to override it instead. I ...
0
votes
0
answers
37
views
Chrome Overrides needs dev tools to be open
I use this great feature and it works perfectly for me but I've noticed that it needs dev tools to be open every time I visit a particular website to work. Is it right or I'm wrong? If yes, what's the ...
0
votes
0
answers
43
views
Pythonic way to override a method from a parent class for any child class
I have a base class with some methods and some (potentially many) child classes which modify some aspects of the base class. Additionally, there is a common modification that I'd like to be able to ...
0
votes
1
answer
27
views
Does my code follows the principle of Polymorphism?
I'm a newbie to Java and I attempt to achieve Polymorphism with the requirements of using the following:
super keyword
overriding
having more than two classes
getting the user's input
using do-while
...
1
vote
2
answers
58
views
Calling overridden methods from a vector of superclass pointers
I am currently writing a small game in OpenGL using C++. Coming from a non-C++ background, I have a simple question about overriding methods and how to call them using a pointer of a superclass type.
...
0
votes
0
answers
27
views
PyCharm does not recognize nested class overriding
I have the following class:
class A:
def __init__(self):
self.my_object = self.NestedClass()
class NestedClass:
def __init__(self):
self.name = "abc"
...
1
vote
1
answer
57
views
Microsoft edge Dev Tools F12 can't save for override (port number indicator : )
I'm using Microsoft edge(latest version-edge 100) and Dev Tools(F12 function key)
When I modified CSS Style on Dev Tools, Sometimes I can't save for override
This problem does occure on same website ...
0
votes
1
answer
30
views
Where i can finde " woocommerce_before_account_navigation" hook and fuction file
This is a code of my account navigation template and i need to change and add some classes to the template that rendered in do_action code that callback a function, i was search in most files of my ...
0
votes
0
answers
20
views
How to override method getDiscountsAction inside OrderController Prestashop 1.7.8
I have a question there is a way to override method getDiscountsAction(int $orderId) inside src/PrestaShopBundle/Controller/Admin/Sell/Order/OrderController.php?
I have overriden OrderController with ...
0
votes
0
answers
18
views
How can override platform tool set for msbuild from command line? How I am doing it is not working
I am pulling in open source project but it is configured to build using MS VS 2015. I am trying to override this command line option on msbuild. But is still tries to use MSVS 2015. Following is my ...
0
votes
0
answers
15
views
Python Multiprocessing Overriding Another Process
I want to make processes that run in parallel, and in certain conditions, different processes will be shut down and different would be running. In the example below, when I press P, I want the ...
0
votes
2
answers
68
views
Overriding element's css in Nebular/Angular
So I am trying to change the css of the header element of the nebular theme in angular
It looks like so
I want it to look like this
I am trying to separate the two elements (the "MyApp" and ...
0
votes
1
answer
12
views
Need to override a js file before pipeline execution
We have a App.js file which has a line of code "if (preLoadSuccess && preLoadData?.Role !== 'NotAuthenticated')".
My need is to override '!==' to '===' when my cypress tests execute ...
0
votes
0
answers
30
views
C# How to call a derived methods?
I have a situation where I want to call only one method and have all the methods its derived from called also.
public class Base
{
public virtual void Method()
{
// Do something
}
}...
0
votes
0
answers
23
views
Override JS file in Liferay module
I want to modify some code in file modules\apps\dynamic-data-mapping\dynamic-data-mapping-form-builder\src\main\resources\META-INF\resources\js\util\fieldSupport.es.js in Liferay 7.3.
I was reading ...
0
votes
1
answer
62
views
not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener
someone can explain to me why it keeps giving me this error
error: MyPanel is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener
public class ...
-2
votes
1
answer
47
views
Is there a way to override methods, in c#, the way you can do in python?
i'm starting to use c# for a unity game project I'm doing in uni, but i mainly use python to program so i was wondering:
is there a way to make an override of a method giving it a standard value if ...
0
votes
0
answers
10
views
Subclass CLlocation error, Use of unimplemented initializer
I'm try to create Subclass of CLLocation in order to be able to make some calculation on the location I retrive from GPS
i have create the following class
class CalculateLocation : CLLocation {
...
1
vote
0
answers
27
views
In java, if Arrays.asList() returns an object that is a list, why to.String method returns it's 'correct' string representation without overriding? [duplicate]
As in title, in java, if Arrays.asList() returns an object that is a list, why to.String method returns it's 'correct' string representation without overriding?
class Person
{
private String name;
...
0
votes
1
answer
31
views
arrayList grow method JAVA overriding that function
please can someone explain to me how to override grow function? I mean the size is grow by old capacity - new capacity /2 +1(for exapmle, Array list collection). How to change that by overridin ...
0
votes
0
answers
25
views
KeyAdapter and KeyEvent is not working in Java, what to do?
So I was trying to make a snake game using the help of BroCode, a youtube channel. I copied the exact same code first to learn but the getkeycode is not working. Means I am pressing the left, right, ...