Public, protected & private

 # public-

# protected-
# private-

class myclass:
class_teacher = "sajita" # public
_protected = "chocolate" # protected
__private = "gf" # private
def __init__(self, aname, aaim):
self.name = aname
self.aim = aaim

student1 = myclass("harish", "software developer")
print(student1._protected)
print(student1._myclass__private) # the process of calling private value is called name mangling

Comments

Popular posts from this blog

Tokens in C

Steps taken by a compiler to execute a C program

Variables and Data Types in C