midhuna peru wrote:yah the same line. No m not getting it. must be silly mistake.
midhuna peru wrote:I din get you. An object for Test1 is created in Test2 class. Memory will be created for Test1 class's object right.
midhuna peru wrote:got it. got it. i initialised object for wrong class! i was trying out inheritance and I did not edit properly.....thanks
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.
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 peru wrote:Thanks Gurpreet Nikhil. i din get it until i typed the code fresh. then i saw difference.