View Single Post
Old Jun 5th, 2006, 9:17 PM   #17
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Thanks for all your help. Somethings in my mind though: In c++ you can pass pointers and refferences into a funtion. So in java is there any simple way to do this? I searched the forums and found "event methods", wow I don't want to get into that. Therefore, this can't be done as it can in c++ can it (create a refference to an object)?

Here's a little example I Found.

#include <iostream>
 #include <stdlib.h>
 

 void swap(int &x, int &y);

 

 int main()

 {

     int x = 5, y = 10;

 

     std::cout << "Main. Before swap, x: " << x 

                                 << " y: " << y << "\n";

     swap(x,y);

     std::cout << "Main. After swap, x: " << x 

                                << " y: " << y << "\n \n \n";
                                
    int x2 = 30, y2 = 40;
    std::cout << "Main. Before swap, x: " << x2 

                                 << " y: " << y2 << "\n";

     swap(x2,y2);

     std::cout << "Main. After swap, x: " << x2 

                                << " y: " << y2 << "\n";
    system("Pause");

     return 0;

 }

 

 void swap (int &rx, int &ry)

 {

     int temp;

 

     std::cout << "Swap. Before swap, rx: " << rx 

                                 << " ry: " << ry << "\n";

 

     temp = rx;

     rx = ry;

     ry = temp;

 

     std::cout << "Swap. After swap, rx: " << rx 

                                << " ry: " << ry << "\n";


 }

Quote:
Source: "Sam's teach yourself c++" by Jesse Liberty
And if the answer is "No java can't do that", wow i'm in a state of shock.


Now back to finishing this tetris game.
__________________
Death smiles at us all. All a man can do is smile back.

Last edited by Eric the Red; Jun 5th, 2006 at 9:36 PM.
Eric the Red is offline   Reply With Quote