a question in NS c programming

Posted by bahar on Stack Overflow See other posts from Stack Overflow or by bahar
Published on 2010-06-13T16:48:08Z Indexed on 2010/06/13 16:52 UTC
Read the original article Hit count: 217

Filed under:

Hi I added a new patch to my NS and I've seen thise two errors. Does anyone Know what I can do?

error: specialization of 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = _AlgorithmTime]' in different namespace from definition of 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = _AlgorithmTime]' and the errors are from this code

typedef struct _AlgorithmTime { // Round. int round; // Fase. int fase; // Valore massimo di fase. int last_fase;

public:

    _AlgorithmTime() {
        round = 0;
        fase = 0;
        last_fase = 0;
    }

    // Costruttore.
    _AlgorithmTime(int r, int f, int l) {
        round = r;
        fase = f;
        last_fase = l;
    }

    // Costruttore.
    _AlgorithmTime(const _AlgorithmTime & t) {
        round = t.round;
        fase = t.fase;
        last_fase = t.last_fase;
    }

    // Operatore di uguaglianza.
    bool operator== (struct _AlgorithmTime & t) {
        return ((t.fase == fase) && (t.round == round));
    }

    // Operatore minore.
    bool operator < (struct _AlgorithmTime & t) {
        if (round < t.round)
            return true;
        if (round > t.round)
            return false;
        if (fase < t.fase)
            return true;
        return false;
    }

    // Operatore maggiore.
    bool operator > (struct _AlgorithmTime & t) {
        if (round > t.round)
            return true;
        if (round < t.round)
            return false;
        if (fase > t.fase)
            return true;
        return false;
    }

    void operator++ () {
        if (fase == last_fase) {
            round++;
            fase = 0;
            return;
        }
        fase++;
    }

    void operator-- () {
        if (fase == 0) {
            round--;
            fase = last_fase;
            return;
        }
        fase--;
    }

}AlgorithmTime;

template<> bool std::less::operator()(const AlgorithmTime & t1, const AlgorithmTime & t2)const { if (t1.round < t2.round) return true; if (t1.round > t2.round) return false; if (t1.fase < t2.fase) return true; return false; } Thanks

© Stack Overflow or respective owner

Related posts about c