Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Pick Semantics: Passing a Vector to a method
Pick Semantics: Passing a Vector to a method [message #40143] Thu, 20 June 2013 21:42 Go to previous message
NeilMonday is currently offline  NeilMonday
Messages: 15
Registered: May 2013
Promising Member
I am learning about pick semantics now. Lets assume I wanted to print a Vector of Strings two times. Am I right in assuming that this will not work:

void PrintNames(Vector<String> names)
{
    for(int i=0; i<names.GetCount(); i++)
    {
        //print the name
    }
}

int main()
{
    Vector<String> myNames;
    //add a few Strings to myNames here...

    PrintNames(myNames);
    //myNames is not valid anymore?
    PrintNames(myNames);
}


Instead I will need to do this:
void PrintNames(Vector<String> names)
{
    for(int i=0; i<names.GetCount(); i++)
    {
        //print the name
    }
}

int main()
{
    Vector<String> myNames;
    //add a few Strings to myNames here...

    Vector<String> tempNames;
    tempNames <<= myNames;
    PrintNames(tempNames);

    tempNames <<= myNames;
    PrintNames(tempNames);
}

 
Read Message
Read Message
Previous Topic: [SOLVED] How to make a Skylark app accessible from outside?
Next Topic: Upp GUI size in Win and Ubuntu
Goto Forum:
  


Current Time: Wed Apr 30 17:33:04 CEST 2025

Total time taken to generate the page: 0.03478 seconds