-1

I have model and in this model contains a function to SUM 1 + 1 Why should I have to make this function non-static?

The difference is an only instantiable class or not?

Calling static function in Controller

Model.sumFunction()

Calling non-static function in Controller

let model = Model()
model.sumFunction

What's a real difference?

1

1 Answer 1

1

The difference is that SubClass of your model class can override non static function whether is class or instance. but SubClass can't override static function.

And the reason behind that is static get one time memory allocation and remains in memory until class remains in memory!

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.