scala - How can an object access the member of super class -


i write following codes:

    class testclass(val mem:int)     object testobj extends testclass(3){       var sum = 5       def apply(a : int, b :int, ext : testclass) = sum + + b + super.mem + ext.mem     }     println(testobj(2,4,new testclass(2)) 

when deleted super.mem method apply, these codes can compiled successfully, want know how can access super member in object?

you don't need add super. in front of mem; use mem, testobj inherits superclass testclass.

class testclass(val mem: int)  object testobj extends testclass(3) {   var sum = 5   def apply(a: int, b: int, ext: testclass) = sum + + b + mem + ext.mem }  println(testobj(2, 4, new testclass(2)) 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -