Nasted class Concept

 

""" Nasted class concept """


class Army:
    def __init__(self,name1):
        self.name=name1
    #instance method
    def show(self):
        print("name :"self.name)
        print()

    #now inner class banabo

    class Gun:
        def __init__(self,capacity1,length1):
            self.capacity=capacity1
            self.length=length1

        def showgun(self):
            print("capacity",self.capacity)
            print("length",self.length)

           
#outer class ar object create
munna=Army("munna")
munna.show()


#inner class ar malpani baire thake acces hoi???
#hobe but tar jonno age object create korte hobe aivabe
objinner=Army.Gun(200,2)

#aibar ai object diye inner class ar attribute abong method sob access korbo
objinner.showgun()



Comments

Popular posts from this blog

D WEB LINK