Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


is throwing exception from a constructor not a good practice ?

Answers were Sorted based on User's Feedback



is throwing exception from a constructor not a good practice ?..

Answer / vikas sood

throwing exception from a constructor is not bad at all. It
is actually advised to use exceptions when you fail to
create your object properly due to any reason. In this case
memory will not be allocated for the object and no
destructor will be called.

Is This Answer Correct ?    11 Yes 1 No

is throwing exception from a constructor not a good practice ?..

Answer / manjunath

Throwing a exception from constructor is perfectly good
habit. That is how to handle errors in the constructor.
Smart pointers can also be used in this scenario.

Is This Answer Correct ?    4 Yes 1 No

is throwing exception from a constructor not a good practice ?..

Answer / dps

ya its better i think because it will take less memory and
less time

Is This Answer Correct ?    0 Yes 0 No

is throwing exception from a constructor not a good practice ?..

Answer / shwetha.v.g

Actualy though when an object is created memory will b
allocated but the process of allocation of memory will be
complete only if conytructor is successfully invoked so if
constructor throws an exception memory will not be
allocated for that object.

Is This Answer Correct ?    1 Yes 6 No

is throwing exception from a constructor not a good practice ?..

Answer / saranya

yes, because constructor does not throws an exception

Is This Answer Correct ?    1 Yes 8 No

Post New Answer

More C++ General Interview Questions

Where must the declaration of a friend function appear?

0 Answers  


What is the use of ‘using’ declaration?

1 Answers  


What's the order in which the local objects are destructed?

0 Answers  


How would you implement a substr() function that extracts a sub string from a given string?

0 Answers  


Is c++ the best programming language?

0 Answers  


What is "mutable" keyword?

2 Answers   Infosys, Teradata,


What does n mean in c++?

0 Answers  


What is size of a object of following class? class Foo { public: void foo(){} }

2 Answers   CA,


Is map ordered c++?

0 Answers  


What is the advantage of an external iterator.

0 Answers  


How does list r; differs from list r();?

0 Answers  


Is it possible to write a c++ template to check for a function's existence?

0 Answers  


Categories