Consider a class whose default constructor takes in the file path as a parameter.
class Test
{
public:
Test(const std::string& filepath);
...
...
};
Now I wish to create and initialize an array of Test
objects using unique pointers in VS2017.
int main()
{
std::unique_ptr<Test[]> m_Tests;
int testCount = 2;
std::string path1, path2;
m_Tests = std::make_unique<Test[]>(testCount); // This line gives a compilation error
m_Tests[0] = std::make_unique<Test>(path1);
m_Tests[1] = std::make_unique<Test>(path2);
}
How can I make this work?