This is my first post and I am a beginner in programming. For my final project I have to implement the functions the professor has given us. This is the project below and my code so far:
A polynomial has one variable x, real number coefficients, and non-negative integer exponents. Such a polynomial can be viewed as having the form: A[n]*x^n + A[n-1]*x^(n-1) + ... A[2]*x^2 + A[1]*x + A[0] where the A[n] are the real number coefficients and x^i represents the variable x raised to the i power. The coefficient A[0] is called the "constant" or "zeroth" term of the polynomial.
**This version works by storing the coefficients in a fixed array. The coefficient for the x^k term is stored in location [k] of the fixed-size array.
#include <iostream>
class polynomial
{
public:
// CONSTANT
static const int CAPACITY = 15;
// CONSTRUCTOR
polynomial(double c=0.0, int degree = 0);
// MEMBER FUNCTIONS
void add_to_coef(double amount, int degree);
void assign_coef(double c, int degree);
void clear();
void print();
int degree() const;
double coefficient(int degree) const;
private:
// DATA MEMBERS
double coef[CAPACITY];
int largest_degree;
};
#include "poly.h"
#include <iostream>
#include <cmath>
using namespace std;
static const int CAPACITY = 15;
///////////need help with this part/////////////
polynomial::polynomial(double c[], int degree)
{
largest_degree = degree;
coef = new double [largest_degree];
for(int i=0; i<largest_degree; i++)
coef[i] = c[i];}
I don't know why the constructor won't compel. What am I doing wrong. Please help!