Or try map<unsigned,long> where 1st arg represents degree (^n) and 2nd represents coefficient. You may declare very interesting class like:
Code:
class Polynom: public std::map<unsigned,long>
{
public: // define poly ops (+,-,*,operator-()) etc
...
};
Add
Code:
ostream& operator << (ostream&,const Polynom&)
and what else and enjoy with full polynomial arith and stream i/o. You may declare Polynom class as wrapper, not as successor of std::map. Anyway it will be a very good practice in OOP...
It seems map container is more suitable than (two) list(s) for polynomes...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.