What is the output of this code? class Temp { public int num = 2; public Temp() { num++;} ~Temp() { num++; } } static void | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

What is the output of this code? class Temp { public int num = 2; public Temp() { num++;} ~Temp() { num++; } } static void

when the object is created the constructor increments the num value by 1 and when the program ends destructors is called which again increments the value by one .So how the answer might be 3?

30th Apr 2019, 2:07 PM
Smit Chawda
Smit Chawda - avatar
0 Réponse