home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,147 of 33,346   
   Neb to All   
   Passing by Reference   
   16 Apr 12 07:04:53   
   
   From: null@nowhere.com   
      
   Hi all,   
      
   Im new to c/c++ programming and am having difficulty in passing more   
   than one parameter into and out of a function.   
      
   //PASS BY REFERENCE   
   #include    
   void swapnum(int &i,int &j)   
   {   
   	int temp = i;   
   	i = j;   
   	j = temp;   
   	return;   
   }   
      
   int main()   
   {   
   	int a = 10;   
   	int b = 20;   
      
   	swapnum(a, b);   
   	printf("A is %d and B is %d\n", a, b);   
   	return (0);   
   }   
      
   In compiling I am recieving the error:   
      
   Error E2293 test.ccp 4: ) expected   
      
      
   Thanks in advance, any help is greatly appreciated.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca