- according to rule we cant define friend function inside the class
- for istream and ostream we always declare friend function (so it is right) in below code
But the problem for 1st point how it can be possible for given code to run successfully ....on GNU (ubuntu) compiler
#include<bits/stdc++.h>
using namespace std;
class dev{
string str;
int n;
public:
friend void operator >>(istream &din,dev &s1)
{
din>>s1.str>>s1.n;
}
friend void operator <<(ostream &dout,dev &s1)
{
dout<<s1.str<<" "<<s1.n;
}
};
int main()
{
dev s2;
cin>>s2;
cout<<s2;
}