Last active
February 23, 2021 19:49
-
-
Save markusbuchholz/887b6675698c5657152f2bf81a0b0e7d to your computer and use it in GitHub Desktop.
return possibilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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