P
P
Pinkman2021-11-24 02:29:44
C++ / C#
Pinkman, 2021-11-24 02:29:44

How to pass an array to a constructor?

Good evening, this is not what you think! I know about new[] =)
I'm doing my simple implementation of smart pointers for c++98. But I can't make a pointer to an array.

my::smart_ptr<int[]> arrN1(new int[10]); // ошибка: now matching constructor for initialization of "my::smart_ptr<int[]>
  std::unique_ptr<int[]> arrN2(new int[10]);

When I add a constructor, it underlines t and writes that there is not enough ')' ... Yes, all quotes and brackets before and after this constructor are normal. How to fix it? And isn't an array a pointer (well, not an array itself, you understand =))? smart_ptr(int[] t) {};

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question