Python:
class Person:
    def __init__(self, fname):
        self.firstname = fname
class User(Person):
    def createPost(self):
        print('Post created by', self.firstname)
Javascript:
class Person {
    constructor(fname) {
        this.firstName = fname;
    }
}
class User extends Person {
    createPost() {
        console.log('Post created by', this.firstName);
    }
}
 

 
    
Top comments (0)