aquaballoon

Pointer / Reference : C++

May 29th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. // Class
  7. class Swap{
  8.     public:
  9.     void jason(int x);
  10. };
  11.  
  12. void Swap::jason(int x){
  13.     //x = 200;
  14.     cout << "Jason_val = " << x << endl ;
  15. }
  16.  
  17. // Function without Class
  18. void lee(int y);
  19.  
  20. void lee(int y){
  21.     y = 200;
  22.     cout << "Lee_val = " << y << endl ;
  23. }
  24.  
  25. // Main Function
  26. int main(void){
  27.     string val = 20;
  28.    
  29.     cout << "Origin_val = " << val << endl;
  30.  
  31.     Swap sp;
  32.     sp.jason(10);
  33.  
  34.     lee(100);
  35.  
  36.     cout << "InMain_val = " << val << endl;
  37.  
  38.     return 0;  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment