Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as C++ by registered user raphael ( 1 year ago )
#include <iostream>
#include "chiffre.h"
#include "paschiffreexception.h"
using namespace std;

int main()
{

    try{
        chiffre mon_chiffre(12);
        mon_chiffre.toString();

    }catch(PasChiffreException ecp1){
        cout<<"La valeur entré n'est pas un chiffre"<<endl;
    }


    return 0;
}
//--------------------------------------------------------------------------------------------------------
#ifndef CHIFFRE_H
#define CHIFFRE_H


class chiffre
{
public:
    chiffre(int ent);
    void toString();
private:
    int entier;
};

#endif // CHIFFRE_H
//--------------------------------------------------------------------------------------------------------
#ifndef PASCHIFFREEXCEPTION_H
#define PASCHIFFREEXCEPTION_H
#include <stdexcept>
using namespace std;
class PasChiffreException : public exception{
public:
    PasChiffreException();
};

#endif // PASCHIFFREEXCEPTION_H
//--------------------------------------------------------------------------------------------------------
#include "chiffre.h"
#include "paschiffreexception.h"
#include <iostream>
using namespace std;
chiffre::chiffre(int ent)
{
    cout<<"L'entier est : "<<ent<<endl;
    if(ent<0 || ent >9){
        throw PasChiffreException();
    }
    this->entier=ent;
}

void chiffre::toString(){
    cout<<"L'entier est : "<<this->entier<<endl;
}
//--------------------------------------------------------------------------------------------------------
#include "paschiffreexception.h"
#include <stdexcept>
#include <iostream>
using namespace std;

PasChiffreException::PasChiffreException()
{
    cout<<"La classe excpetion PasChiffreException est appellé !"<<endl;
}

 

Revise this Paste

Your Name: Code Language: