Skip to content

Instantly share code, notes, and snippets.

@markusbuchholz
Last active February 23, 2021 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markusbuchholz/887b6675698c5657152f2bf81a0b0e7d to your computer and use it in GitHub Desktop.
Save markusbuchholz/887b6675698c5657152f2bf81a0b0e7d to your computer and use it in GitHub Desktop.
return possibilities
#include <iostream>
#include <vector>
#include <string>
struct privType
{
int xx;
double yy;
std::string str;
};
std::vector<int> testFunction()
{
int xx = 10;
int yy = 20;
std::vector<int> returnVector;
returnVector.push_back(xx);
returnVector.push_back(yy);
return returnVector;
}
std::vector<privType> testFunctionPrivType()
{
privType toReturn;
std::vector<privType> returnVector;
toReturn.xx = 10;
toReturn.yy = 3.1415;
toReturn.str = "Bjarne Stroustrup";
returnVector.push_back(toReturn);
toReturn.xx = 1000;
toReturn.yy = 2.7182;
toReturn.str = "Linus Torvalds";
returnVector.push_back(toReturn);
return returnVector;
}
int main()
{
std::vector<int> printVector = testFunction();
std::vector<privType> printPrivVector = testFunctionPrivType();
for (auto &ii : printVector)
{
std::cout << "> " << ii << std::endl;
}
for (auto &ii : printPrivVector)
{
std::cout << ">> " << ii.xx << " >> " << ii.yy << " >> " << ii.str << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment