Why extra object when initialising vector of custom class objects | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why extra object when initialising vector of custom class objects

Hello Please refer code below : When I initialise five object of class without any argument to constructor, it seems ok If I decide to go with parametric constructor for 5 objects, why am I able to observe 6 destructor calls ? https://code.sololearn.com/c0L2B0cdpJ7p/?ref=app

23rd Apr 2022, 8:33 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Answers
+ 4
This is weird, where are you observing the 6th call ? https://code.sololearn.com/c20D8c5993Hd/?ref=app
23rd Apr 2022, 9:34 AM
Arsenic
Arsenic - avatar
0
Due to some issue currently at sololearn on mobile app for Android, I cannot check your entire code as still only having first few lines However I got idea of increasing count for each constructor call. Doing so also, got the count of constructors as 6 as updated in code. So , still issue of additional constructor call is there.. And I never thought of making member variables as inline... What's the advantage of same ? Only inline functions I have seen earlier but not member variables as inline
23rd Apr 2022, 12:22 PM
Ketan Lalcheta
Ketan Lalcheta - avatar