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:
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>.
#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);
}
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>.
ASKER
Sorry I deleted the comments so it would take up as much space.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh my! 13 seconds faster :)))
http://www.youtube.com/watch?feature=player_detailpage&v=MsK6aRuSBIc#t=134
Oh no, not again!
http://www.youtube.com/watch?feature=player_detailpage&v=MsK6aRuSBIc#t=134
Now that's interesting, because the above code is only 32 lines...