To catch an error from a constructor | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

To catch an error from a constructor

An exception (named invalid) was thrown from a constructor of class ( named myclass). try and catch was used to handel the exception in main function. Initialisation of a new variable (of user defined type myclass) was done int the try block. I could not use the defined variable outside the try block. i used try and catch only to catch invalid (thrown from constructor) but i need to use new variable in my program. please help me to fix this code for reference : https://code.sololearn.com/cn1eS1Ja7DV4/#cpp

22nd Dec 2019, 10:26 AM
Chetan Satpute
Chetan Satpute - avatar
0 Réponse