Error in array pointers? REPLY FAST!!!!!

I am building an advanced calculator program and I am getting errors on line 22 when I compile the following code.

Main.cpp (no error)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 #include <iostream>
#include <new>
#include <sstream>
#include <array>
#include <memory>
#include <string>

#include "Calculator.h"

using namespace std;

int main()
{
    string equation;
    Calculator calc;

    while (true)
    {
        cin >> equation;
        calc.setArr(equation);

    }

}


Calculator.h (no error)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <new>
#include <sstream>
#include <memory>
#include <array>
#include <string>

using namespace std;

class Calculator
{
    public:
        Calculator();
        void        print();
        void        interpret();

           //Get/Sets
        void        setArr(string newArr);
        string      getArr();
        void        setOper(char newOper);
        char        getOper();
        void        setOp1(double op1);
        double      getOp1();
        void        setOp2(double op2);
        double      getOp2();

          //Calculation
        void        add();
        void        subtract();
        void        multiply();
        void        divide();

    private:
        shared_ptr<double> arr;      //Full equation
        string      sArrAccess;      //Size of array = size of sArrAccess string
        double      operandOne;      //First operand
        double      operandTwo;      //Second operand
        char        oper;

};


Calculator.cpp (ERROR!!!)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "Calculator.h"

Calculator::Calculator()
{
    arr = nullptr;
    sArrAccess = "";
}

void Calculator::print()
{

}

void Calculator::interpret()
{

}

void Calculator::setArr(string newArr)
{
    newArr = sArrAccess;
    *arr = new array<double, sArrAccess.size()> // error!
    for (auto& i : sArrAccess)
    {

    }
}

string Calculator::getArr() {return Calculator::sArrAccess;}

void Calculator::setOper(char newOper)
{

}

char Calculator::getOper(){return oper;}

void Calculator::setOp1(double op1)
{

}

double Calculator::getOp1() {return operandOne;}

void Calculator::setOp2(double op2)
{

}
double Calculator::getOp2(){return operandTwo;}


What is this??

EDIT:
I tried using C style arrays and I get an error that says:
 
error: cannot convert 'double*' to 'double' in assignment
Last edited on
should i convert the smart pointer to a regular ptr?
closed account (2UD8vCM9)
You shouldn't be using std::array in the first place. They aren't resizable.

You should use vectors instead.

You also shouldn't hijack other people's threads asking for help.
Last edited on
Sorry about that.. I was desperate for answers :/

Any ways, in the pointer declaration do I do double or double[]?
closed account (2UD8vCM9)
You don't do a pointer declaration at all.

Just #include <vector>

Do vector<double> arr;
Topic archived. No new replies allowed.