W
W
Wasya UK2017-09-24 15:47:14
Microsoft
Wasya UK, 2017-09-24 15:47:14

How to correctly multiply a polynomial by a number?

Why can't I multiply a polynomial by a number?
[Error] no match for 'operator<<' (operand types are 'std::basic_ostream' and 'Polynom')
Call: In class:
cout << "5 * g = " << g * 5 << endl;

Polynom Polynom::operator *(double c) {
  return multiple(c, *this);
}

Polynom multiple(double c, const Polynom& p) {
  if (c == 0) {
    Polynom result;
    return result;
  } else {
    int degree = p.degree;
    double* new_exponents = new double[degree];
    
    for (int i = 0; i < degree; i++) {
      new_exponents[i] = c * p.exponents[i];
    }
    
    Polynom result(degree, new_exponents);
    delete[] new_exponents;
    
    return result;
  }
}

ostream& operator <<(ostream& os, Polynom& p) {
  os << "{ degree: " << p.degree << "; coefficients: " << p.getCoefficientsStr() << " }";
  
  return os;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2019-06-11
@feanor7

But as far as I understand, this is unprofitable. it will have more cores than server hardware.

Wrong. https://habr.com/ru/post/321708/
Now licensing is built on physical cores, usually sold in pairs of licenses, that is, if you have 16 physical cores, then you buy 8 licenses for 2 cores.
Server CAl - by the number of users.
RDP CAL is either per user or per device, it all depends on your needs.
Here is another FAQ for you https://msbuy.ru/help/default.aspx?q=faq&sid=8

A
alexhott, 2019-06-26
@alexhott

there is such a moment
server Windows:
for one physical server you need to buy licenses for at least 16 cores, even if it really has only 2 of them
, starting with 16 cores in packages of 2 licenses or 8
each, then you need either a kala user or a kala device
here if you have 65 users work in turn on 10 PCs, then we take a device of feces, if 65 users and 65 PCs and users still cling to the server through mobile devices, then we take users.
If the server is used as a web server - with an unknown number of connections - there is a special RDP license for this,
if there is one connection, then you do not need to buy

G
GavriKos, 2017-09-24
@GavriKos

You can multiply. You cannot output it through cout, which is what is written in the error. The << operator is not overloaded for POlynom

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question