Link to home
Start Free TrialLog in
Avatar of Angela Stevenson
Angela Stevenson

asked on

Unknown scope in pair.h

When I made a small change to get it to check the syntax, I am getting unknown scope:


#ifndef PAIR_H
#define PAIR_H
#endif

#include <bool.h>

template<class T1, class T2>
struct pair {
    T1 first;
    T2 second;
    pair() : first(T1()), second(T2()) {}
    pair(const T1& a, const T2& b) : first(a), second(b) {}
    friend void destroy(pair<T1, T2>* p) {
//Ed Y.      p->~pair();
    }
};

template<class T1, class T2>
inline iBOOL operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
    return x.first == y.first && x.second == y.second; 
}

template<class T1, class T2>
inline iBOOL operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
    return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
}

template<class T1, class T2>
inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
    return pair<T1, T2>(x, y);
}

Open in new window

I get the following errors when compiling in Unix:

line 33: Error: The name pair is ambiguous, pair<T1, T2> and std::pair<std::_T1, std::_T2>.
line 38: Error: The name pair is ambiguous, pair<T1, T2> and std::pair<std::_T1, std::_T2>.
line 43: Error: The name pair is ambiguous, pair<T1, T2> and std::pair<std::_T1, std::_T2>.
Avatar of jkr
jkr
Flag of Germany image

>>line 33: Error

Now that's interesting, because the above code is only 32 lines...
Avatar of Angela Stevenson
Angela Stevenson

ASKER

Sorry I deleted the comments so it would take up as much space.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial