It is not possible to assign an element std :: array directly, it says that the "=" operator does not match

There processoris an array in my class <Job, 10>.

void Processor::addJob(Job job) {
    this->Jobs[this->uBound] = job;
    this->uBound++;
}

I want to add a new element inside my class processor. To do this, I create a new property private: int uBound = 0in my class processor. and I appoint directly this->Jobs[this->uBound] = job;. it gives me an error. he says Error : no operator "=" matches these operands. operand types are: std::array<Job, 10U> = Job.

so I tried to use this->Job->assign(Job); it is assigned to all elements of mine Jobs, but I just need only one element.

here is the class Job

class Job {
public:
    string name;

public :
    int length = 0;

public:
    bool used = false;

public:
    Job();

public:
    Job(string n, int l);


    ~Job();
};

and here is the class processor

class Processor {

private:
    int turnArround_time = 0;

private:
    int uBound = 0;

public:
    std::array<Job, 10> *Jobs = new std::array<Job, 10>();

public:
    Processor();

public:
    void addJob(Job job);

public:
    int getTurnArround();




    ~Processor();
};

I have no idea what the error means.

Is there an alternative way to add an object Jobto Processor->Jobs? any help appreciated, thanks ...

+4
1

(* this- > Jobs) [this- > uBound] = job;

, .

, , :)

this->Jobs[0][this->uBound] = job;

.

+9

Source: https://habr.com/ru/post/1585097/


All Articles