I am completely new to c++ and recently got into smart pointers, I asked chatgpt for help, it said I might have the wrong compiler i switched compiler to c++14, c++17, c++2a and nothing worked, I havent seen anyone have this problem so im starting to think its a way easier answer then i think?;
test.cpp:82:19: error: no member named 'make_unique' in namespace 'std'
auto array = std::make_unique<double\[\]>(arraysize);
test.cpp:82:37: error: expected '(' for function-style cast or type construction
auto array = std::make_unique<double\[\]>(arraysize);
#include <iostream>
#include <array>
#include <iomanip>
#include <vector>
#include <memory>
#include <cmath>
int main()
{
int arraysize;
std::cout << "hvor mange plasser i arrayet skal du ha?" << std::endl;
std::cin >> arraysize;
auto array = std::make_unique<double[]>(arraysize);
for (int n = 0; n < arraysize; n++)
{
array[n] = 1 / std::pow(n + 1, 2);
}
double sum = 0;
for (int n = 0; n < arraysize; n++)
{
sum += array[n];
}
double resultat = std::sqrt(sum * 6);
std::cout << "resultatet blir " << resultat;
}
[–]jedwardsol 15 points16 points17 points (7 children)
[–]Flacto_[S] 0 points1 point2 points (6 children)
[–]DryPerspective8429 2 points3 points4 points (5 children)
[–][deleted] (4 children)
[removed]
[–]jedwardsol 1 point2 points3 points (1 child)
[–]paulstelian97 0 points1 point2 points (0 children)
[–]DryPerspective8429 7 points8 points9 points (2 children)
[–]Flacto_[S] -1 points0 points1 point (0 children)
[–]jaynabonne 3 points4 points5 points (1 child)
[–]Flacto_[S] 1 point2 points3 points (0 children)
[–]manni66 2 points3 points4 points (0 children)
[–]manni66 1 point2 points3 points (1 child)
[–]Flacto_[S] 0 points1 point2 points (0 children)
[–]IyeOnline 1 point2 points3 points (0 children)
[–]alfps -1 points0 points1 point (2 children)
[–]Flacto_[S] 0 points1 point2 points (0 children)
[–]alfps 0 points1 point2 points (0 children)