Overriding a function in an extended class, with different arguments.
in
Programming Questions
•
11 months ago
Hi, i get an error when trying to override a function in an extended class, i wonder if someone can help me with this. Basically, what i want to do is to override a function but calling it with different arguments:
- void setup() {
- Thing thing = new anotherThing();
- thing.function(); // this works, but calls the function in the main class.
- //thing.function(new PVector()); // this doesn't work
- }
- class Thing {
- Thing() {
- //some code
- }
- void function() {
- // This function has no arguments
- println("this is Thing's function, with no arguments");
- }
- }
- class anotherThing extends Thing {
- anotherThing() {
- super();
- //some extra code
- }
- void function(PVector aVector) {
- println("this is AnotherThing's function, called with an argument " + aVector);
- }
- }
Thanks for any help!
1