+ 2

What's wrong in array of parametric constructor

Hi Please refer code below: https://code.sololearn.com/cuhJ1df0oDys Can anyone please help me understand issue of clsTest* p3? what's missing here or it is not at all allowed?

6th Apr 2022, 12:21 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 ответов
+ 3
look like you want to create an array and each element of array is initialized by clsTest at line 42 write this clsTest * p3 = new clsTest[3]{{1},{2},{3}} delete[] p3 // i think your version is not allowed because we can't initialize pointer with aggregate (multiple values) (just guessing) check this, 👍 https://code.sololearn.com/c3CSCyzT1vrB/?ref=app
6th Apr 2022, 2:27 PM
NonStop CODING
NonStop CODING - avatar
+ 1
Thank you so much... It worked .... Now tried with unique pointer but again got stuck for unique pointer
6th Apr 2022, 5:25 PM
Ketan Lalcheta
Ketan Lalcheta - avatar