Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-08-2009
Member
 
Join Date: Oct 2008
Posts: 105
How to pass reference to vector objects

I was reading about the descriptions in which it was telling about the referencing in Java, now I decided to modify the values of a vector within a function where I declare the vector outside that function. How to pass a reference or pointer to that data structure. What would be the corresponding object in STL?
Reply With Quote
  #2  
Old 07-08-2009
Member
 
Join Date: Jan 2009
Posts: 143
Re: How to pass reference to vector objects

you have to create a specialization, or instance, of a vector and then pass it by reference to a function. For example, to pass a vector of int's, Vectors are a kind of sequence containers. As such, their elements are ordered following a strict linear sequence. Compared to arrays, they provide almost the same performance for these tasks, plus they have the ability to be easily resized.
Reply With Quote
  #3  
Old 07-08-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: How to pass reference to vector objects

Although, they usually consume more memory than arrays when their capacity is handled automatically (this is in order to accomodate for extra storage space for future growth). I want the vector to be passed by reference so that whatever changes I make in it in session bean method, these are reflected beack in client without returning the vector. Compared to the other base standard sequence containers (deques and lists), vectors are generally the most efficient in time for accessing elements and to add or remove elements from the end of the sequence.
Reply With Quote
  #4  
Old 07-08-2009
Member
 
Join Date: Oct 2008
Posts: 167
Re: How to pass reference to vector objects

What else travels on this socket? If it is your own protocol then add a verb to the protocol that says "get that big thing from a known location" and just send the verb. When a reference variable is passed to another function, its value can be changed in the function. This is similar to how variable may be changed in a function by passing a pointer to the variable. That is, a complete copy of its current state gets passed over the wire to the EJB, which "deserializes" it into a copy of the original vector.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to pass reference to vector objects"
Thread Thread Starter Forum Replies Last Post
Pass Variables By Reference in Javascript? MAGAR Software Development 5 11-03-2010 04:11 PM
Polymorphism and objects stored in a vector New ID Software Development 5 03-03-2010 09:45 AM
Vector objects and methods Miles Runner Software Development 5 26-02-2010 04:14 AM
How to sort vector objects by class member variables in c++? Linoo Software Development 4 29-01-2010 07:15 PM
What is difference between pass by value & pass by reference in java? Baran Software Development 4 25-02-2009 07:15 PM


All times are GMT +5.5. The time now is 09:20 PM.