i want to print the polynom. i dont know already if its a syntax problem or that i just dont understand something
class polynom : public func {
public:
polynom(const int order, int* ptr_array);
polynom(const polynom& polynom_);
void printcoefs(ostream&) const ;
friend polynom operator+(polynom const &, polynom const &) ;
friend polynom operator-(polynom const &, polynom const &);
friend polynom operator*(polynom const &, polynom const &);
polynom operator=(polynom const & poly) { //assignment operator
int* ptr = new int[poly.n_ + 1];
for (int i = 0; i < poly.n_ + 1; i++)
ptr[i] = poly.coefs_[i];
return polynom(poly.n_, ptr);
}
polynom Derivative();
polynom Integral();
int funcout(const int& x) const;
friend ostream & operator<<(ostream& out, const polynom& polynom_);
~polynom();
void Print(ostream& out) const;
protected:
int n_; //order of the polynom
int* coefs_; //coefficients
};
this is what i wrote for the pritning functions
void polynom::Print(ostream &out) const {
printcoefs(cout);
cout << endl;
cout << "Derivative: ";
polynom der=this->Derivative; <-error here
der.printcoefs(cout);
cout << endl;
polynom inte =this->Integral;
cout << "Integral: ";
inte.printcoefs(cout);
cout << endl;
}
ostream & operator<<(ostream & out, const polynom & polynom_)
{
polynom_.Print(out);
return out;
}
it gives me either Error C3867 'polynom::Derivative': non-standard syntax; use '&' to create a pointer to member , if i write it like this. Error C2276 '*': illegal operation on bound member function expression ,if i try to use "this" as a pointer. any help will be appreciated
Aucun commentaire:
Enregistrer un commentaire