midhuna peru wrote:yah the same line. No m not getting it. must be silly mistake.
Okay, to make it interesting and more understandable to you i am not giving you the correct answer but i am going to ask you some questions, answer me and you will find it out by your self okay.
Tell me the name of the place where you are getting this error ?
No, we call that place- is a place where we declare static or non-static variables.
Addition- If it is a non-static then it will go into the object of enclosing class. in your case it will go into the Test2 class's object.
you cannot have executable code inside the class but outside any methods . you are assigning t1.no = 10; which must be put in method/initializer rather than writing it inside the class.
gurpeet singh wrote:you cannot have executable code inside the class but outside any methods . you are assigning t1.no = 10; which must be put in method/initializer rather than writing it inside the class.
oh right right. Except declaration everything should be inside method. silly of me....i knew it will be stupid mistake. so much for changing a code. next time i should type code fresh if changes are major. Thanks so much.
midhuna peru wrote:oh right right. Except declaration everything should be inside method. silly of me....i knew it will be stupid mistake. so much for changing a code. next time i should type code fresh if changes are major. Thanks so much.
midhuna, one more thing i noticed that can lead to trouble that always use protected members of the super class through inheritance instead of by using association.
for example.
hey! this is what my code was first. Ofcourse Test1 was not public I just copied and edited in new file and ended up with trouble. When I Typed code fresh i did it right . only on comparing edited code and fresh code i understood the mistake.
Anyway whats wrong with Base Class being Public?
Post by:autobot
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
a bit of art, as a gift, that will fit in a stocking