01.05.2013 Views

C++ et éléments finis Note de cours de DEA (version provisoire)

C++ et éléments finis Note de cours de DEA (version provisoire)

C++ et éléments finis Note de cours de DEA (version provisoire)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

48 CHAPITRE 7. ALGÈBRE DE FONCTIONS<br />

Fonction(const Cvirt *ff) : f(ff) {}<br />

Fonction(R (*ff)(R)) : f(new Cfonc(ff)) {}<br />

Fonction(R a) : f(new Cconst(a)) {}<br />

operator const Cvirt * () const {r<strong>et</strong>urn f ;}<br />

Fonction operator+(const Fonction & dd) const {r<strong>et</strong>urn new Coper(Add,f,dd.f);}<br />

Fonction operator-(const Fonction & dd) const {r<strong>et</strong>urn new Coper(Sub,f,dd.f);}<br />

Fonction operator*(const Fonction & dd) const {r<strong>et</strong>urn new Coper(Mul,f,dd.f);}<br />

Fonction operator/(const Fonction & dd) const {r<strong>et</strong>urn new Coper(Div,f,dd.f);}<br />

Fonction operatorˆ(const Fonction & dd) const {r<strong>et</strong>urn new Coper(Pow,f,dd.f);}<br />

} ;<br />

using namespace std ; // introduces namespace std<br />

R I<strong>de</strong>ntite(R x){ r<strong>et</strong>urn x ;}<br />

int main()<br />

{<br />

Fonction Cos(cos),Sin(sin),x(I<strong>de</strong>ntite);<br />

Fonction f((Cosˆ2)+Sin*Sin+(x*4)); // attention ˆ n’est prioritaire<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!