/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <vector>
using namespace std;
class Poly
{
struct Mono
{
char sign = 1;
double power;
double multiplier;
void operator=(double multiplier)
{
this->multiplier = multiplier;
}
};
public:
void addPolyComponent(double multiplier , double power, char sign = 1)
{
Mono mono;
mono.multiplier = multiplier;
mono.power = power;
mono.sign = 1;
polyComponents.push_back(mono);
}
Mono& operator[](double v)
{
Mono mono;
mono.power = v;
mono.sign = 1;
polyComponents.push_back(mono);
return polyComponents.back();
}
private:
vector<Mono> polyComponents;
};
int main()
{
Poly P1; //Declare object representing polynomial P1
P1[3] = 2; P1[1] = 3.6; P1[0] = 7; //Specify coefficients of P1 = 2x^3 + 3.6x + 7
Poly P2;// = 5;//UWAGA!!!To jeszcze nie jest zdefiniowane, dlatego wykomentowałem //Declare object representing polynomial P2 = 5
P2[1] = 3; P2[2] = 6; P2[4] = 1; //Specify additional coefficients of P2 = x^4 + 6x^2 + 3x + 5
int i = 0;// podgląd zawartości P1 i P2 debuggerem, po postawieniu breakpointa w tej linii
return 0;
}