| Author |
Multiple inheritance (cannot reference name before supertype constructor has been called)
|
deepu bhadriraju
Greenhorn
Joined: Aug 01, 2012
Posts: 8
|
|
[Added code tags - see UseCodeTags for details]
please help me out
I am getting the error in child class class constructor i.e in super(name,dd,mm,yyyy,salary)
cannot reference name before supertype constructor has been called
cannot reference dd before supertype constructor has been called
cannot reference mmbefore supertype constructor has been called
cannot reference yyyy before supertype constructor has been called
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Let's take this example which is simplified version of your problem
you are trying to pass str which is not yet initialized to super constructors.
note: subclass constructor runs *only* successful of super class constructors
|
 |
deepu bhadriraju
Greenhorn
Joined: Aug 01, 2012
Posts: 8
|
|
Seetharaman Venkatasamy wrote:Let's take this example which is simplified version of your problem
you are trying to pass str which is not yet initialized to super constructors.
note: subclass constructor runs *only* successful of super class constructors
Sorry cant get you .can you make necessary changes to my code please
|
 |
dennis deems
Ranch Hand
Joined: Mar 12, 2011
Posts: 808
|
|
deepu bhadriraju wrote:
|
 |
deepu bhadriraju
Greenhorn
Joined: Aug 01, 2012
Posts: 8
|
|
Dennis Deems wrote:
deepu bhadriraju wrote:
Name ,dd,mm,salary refer to variable of grand-parent class..I rectified my mistake.what iam trying to make call the super class constructor without assigning values to it
NOW changed code is
public Trainee(int m1, int m2, int m3,String name,int dd,int mm,int yyyy,int salary)
{
super(name, dd, mm, yyyy,salary);
this.m1 = m1;
this.m2 = m2;
this.m3 = m3;
}
|
 |
 |
|
|
subject: Multiple inheritance (cannot reference name before supertype constructor has been called)
|
|
|