How can i send the object of vector to a function?

0 views
Skip to first unread message

bahador saket

unread,
Mar 4, 2010, 11:04:05 PM3/4/10
to fit-ca...@googlegroups.com
Dear all

I want to know how can i send the objects of vectors to a function.

for example:
 

 void function(  ?????????????????????? )
 {
     // it shows the list of employees
 }
 class A{
 
   ......
   .....
 };

int main()
{
     vector<A> object1;
     function(????????????????);
  
}



Regards,
Bahador

Snail Lee

unread,
Mar 5, 2010, 2:17:58 AM3/5/10
to fit-ca...@googlegroups.com
// move your class A above function, else there will be compiler error
class A
{
     ...
};

// ampersand(&) indicates pass by reference
void function(vector<A>& v)
{
     ...

}

int main()
{
     vector<A> object1;
     function(object1);
     ...
}

Good luck.

Snail



bahador saket

unread,
Mar 5, 2010, 8:45:46 AM3/5/10
to fit-ca...@googlegroups.com
Dear friends

Tnx for your helps.
i can solve my problem.


Regards,
Bahador Saket
Reply all
Reply to author
Forward
0 new messages