Hi all here is my pair.h file which when I run using g++ on linux I am getting error like
"pair.h:39: error: expected constructor, destructor, or type conversion before ‘ostream’"
any help would be greatly appreciated!
Thanks
WRAP
template <class T1, class T2>
class pair2 {
private:
T1 first_;
T2 second_;
//friend ostream& operator << <T1,T2>(ostream& os, pair2<T1,T2> const& p);
// friend istream& operator >> <T1,T2>(istream& is, pair2<T>& p);
public:
//pair2(){};
pair2():first_(0),second_(0){};
pair2(const T1 &a, const T2 &b){
first_= a;
second_= b;
}
~pair2(){}
void set_first (const T1& a) {first_= a;}
void set_second(const T2& b) {second_= b;}
void swap(){
T1 temp = second_;
second_= static_cast<T2>(first_);
first_= static_cast<T1>(temp);
}
T1 first()const {return first_;}
T2 second()const {return second_;}
bool operator==(pair2 const& c)const{
bool bool1;
bool1= ((this->first_ == c.first())&&(this->second_==c.second()));
return bool1;
}
};
template <class T1, class T2> pair2
ostream& operator<<(ostream& os, pair2 <T1,T2> const& c){
os<<c.first()<<" "<<c.second()<<endl;
return os;
}