...

View Full Version : Inheritance using multiple constructors.



Marcuss
04-23-2008, 03:19 PM
Hello.

I'm having some small issues when attempting to extend a class. The example is an abstraction of what i'm attempting to do, but it still produces the same error message.


class Inheri{

protected Object ar;
protected Inheri1 ir;

public Inheri(Object o){
ar = o;
}

public Inheri(Object o, Inheri1 i){
ar = o;
ir = i;
}

//any old methods

}

And i'd like to just extend it, so:


class Inheri1 extends Inheri{

protected int yarr;

public Inheri1(){

//doesn't matter what goes here

}

}

It's producing the error message :


./Inheri1.java:5: cannot find symbol
symbol : constructor Inheri()
location: class Inheri
public Inheri1(){}
^

It seems to not like multiple constructors in the Inheri class, but I'm not entirely sure how to resolve it, as far as I can see everything is fine. I'm sure I'm sure I'm lacking an elementary understanding here though.

Thank you for any help in advance.

-Marcus

Aradon
04-23-2008, 06:36 PM
Are you calling super? If so how are you calling it? just super() or super(object) ?

Also, why are you using Inheri1 in your Inheri class?

You want your Inheri1 class to handle Inheri1 objects and your Inheri class to handle Inheri objects (and those in which are sub-divided into it)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum