Assign new value to an object in a function
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Assign new value to an object in a function

Threaded View

  1. #1
    Join Date
    Oct 2004
    Location
    Ho Chi Minh, Vietnam
    Posts
    126

    Assign new value to an object in a function

    Hi,
    I want to pass an object to another function (of another class) to assign new value to it: code below
    Code:
    public class MyClass
    	{
    		InfoSupplier infosupplier;
    		 
    		
    		public void myFunc(){
    			Info infocarrier = new Info(); 
    			this.infosupplier.supply(infocarrier); //infosupplier has already been declared and allocated elsewhere
    			
    			//the problem is after this line, infocarrier still doesn't have the new values (members)
    			//which means the assignment inside the function supply() is NOT effective
    			
    		}
    		
    		
    		
    	}
    	
    	public class InfoSupplier
    	{
    		Info info; 
    		public void supply (Info ic)
    		{
    			ic = this.info ;//this.info has been declared and allocated, assigned value elsewhere
    			
    		}
    	}
    What is wrong with the assignment? Given everything in Java is pointer
    Thanks.
    Last edited by choconlangthang; August 8th, 2010 at 04:08 AM. Reason: missing the question :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center