Learn about constructor and destructor | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Learn about constructor and destructor

write a function called power(n , p) which takes double value for n and int value for p and returns a result as a double value.use a default argument of 2 for p.write a main() function that gets the value from user.use appropriate constructor and destructor.

14th Feb 2018, 12:54 PM
Moksh R Solanki
Moksh R Solanki - avatar
3 Answers
+ 1
No constructor or destructor is needed in this coding question. Is there any more information? I presume it's C++.
31st Mar 2018, 9:35 AM
Emma
+ 1
Ya,not needed right but i try to solbe this with constructor and destructor for the practice
22nd May 2018, 3:41 PM
Moksh R Solanki
Moksh R Solanki - avatar
+ 1
You can use a constructor to set the object values, n and p But no need for deconstructor you don't need the allocate memory so no deconstructor
21st Jan 2019, 11:34 PM
Abel Louis
Abel Louis - avatar