Lecture 6 Constructor and Destructor OOP 1: Video ( ith attribu its. GameC init elf.nan elf.hea f.lev show int(f class MyClass: def _init__(self, name): self.name = name print(f'{self.name} created") def _del_(self): print(f'{self.name} destroyed") # Creating objects and adding multiple references a = MyClass("Object A" b=a #b points to the #Deleting one reference output del a # destructor will not be called because b still points to the object #Deleting all references del b # Now there are no references to the object, so destructor will be called cat veli ar whar

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question
Lecture 6 Constructor and Destructor
OOP
1: Video (
ith attribu
its.
GameC
init
elf.nan
elf.hea
f.lev
show
int(f
class MyClass:
def
_init__(self, name):
self.name = name
print(f'{self.name} created")
def _del_(self):
print(f'{self.name} destroyed")
# Creating objects and adding multiple references
a = MyClass("Object A"
b=a #b points to the
#Deleting one reference
output
del a # destructor will not be called because b still points to the object
#Deleting all references
del b # Now there are no references to the object, so destructor will be called
cat
veli
ar
whar
Transcribed Image Text:Lecture 6 Constructor and Destructor OOP 1: Video ( ith attribu its. GameC init elf.nan elf.hea f.lev show int(f class MyClass: def _init__(self, name): self.name = name print(f'{self.name} created") def _del_(self): print(f'{self.name} destroyed") # Creating objects and adding multiple references a = MyClass("Object A" b=a #b points to the #Deleting one reference output del a # destructor will not be called because b still points to the object #Deleting all references del b # Now there are no references to the object, so destructor will be called cat veli ar whar
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr