overloading operators

closed account (SECMoG1T)
Hi i have a little wierd question here,on overloading operators outside classes, for me it seems impossible and unheard of, if possible i will certainly like it coz am really in need of such a function, see below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  template<typename T>
  /**actually i dont know what to return**/
  /**type**/ input(istream& in,T my_var)
   {
        ///some code here
        ///stuff like stream checks,input validation,many more
   }

   //if the ffunction is defined i could use it like this
   
    int main()
     {
       string temp, data,data1;
       int temp,val;
       vector<int> myvec;

        input(cin,temp)>>data;
        input(cin,temp)>>data1;//like this

        for(int i=0;i<10;i++)
         {
           myvec.push_back(input(cin,temp)>>val);//all this miracles
         }
         
        
        }
      


thats what i was talking about "haha", is it really possible?
Last edited on
Topic archived. No new replies allowed.