Skip to content
Advertisement

Trouble calling methods from a class/ [closed]

Can someone tell me whats wrong with these codes ?

JavaScript

and this

JavaScript

It shows the error:

Multiple markers at this line

on the line where i call the student.getDetails(n,r)

Advertisement

Answer

You cannot call a method in a class without it being wrapped in a method.

Your Student class also lacks a constructor (a method that is called when the class is instantiated) and lacks the context of attribute visibility (public/protected/private). The constructor must call itself as the class, in your case:

JavaScript

Once you have structured the class correctly, you need to do the following to instantiate it:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement