Cours:DevoirPOOcpp1
Programme pour démarrer
Header :
#include <iostream>
using namespace std;
class Fraction
{
public:
Fraction(int, int);
string tostring();
private:
int num;
int denom;
};
Implémentation :
Fraction::Fraction(int _num, int _denom)
{
num = _num;
denom = _denom;
}
string Fraction::tostring()
{
return to_string(num)+"/"+to_string(denom);
}
Programme principal :
int main()
{
cout << "Evaluation POO n°1" << endl;
Fraction f1(1,2);
cout << "f1=" << f1.tostring() << endl;
return 0;
}