FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   class extending weirdy
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: class extending weirdy  (Read 247 times)
skloopy

WWW
class extending weirdy
« on: May 19th, 2004, 4:11am »

I'm not sure if this is a bug or something i'm doing wrong so i'm putting it in syntax. When I try to extend a class that already has a constructor, P5 gives me an error and says that i should use the parent class's constructor.. It's weird, try it out
 
Code:
void setup() {}
void loop() {}
 
class Fostermom extends Hoops
{
  Fostermom(float earrings, String yell, int vodkas)
  {
  }
}
 
class Hoops
{
  Hoops(float howmany, boolean yoyoyo)
  {
  }
}

If you take all of the inputs out of Hoops it'll work tho..
 
justo


Re: class extending weirdy
« Reply #1 on: May 19th, 2004, 4:30am »

when java constructs a class it implicitly calls super() as the first call...the default constructor of its super class (this is how all objects descend from Object...super() calls all the way to the top).
 
youve made a class that overrides the default constructor, so you have to explicitly call it as the first line:
 
Code:
Fostermom(float earrings, String yell, int vodkas) {
   super(someFloat, someBool);
   ...
}
 
skloopy

WWW
Re: class extending weirdy
« Reply #2 on: May 19th, 2004, 7:14am »

Okay I guess that makes sense.. Actually it's pretty convenient.
 
THanks justo!
 
ryan
 
Pages: 1 

« Previous topic | Next topic »